I don't really understand what causes the error i checked the documentations and there was a very similar example of this one here is my views.py, urls.py under my app i use include, and the template
views.py
class SchoolListView(ListView):
context_object_name = 'schools'
model = models.School
urls.py
from django.urls import path
from . import views
#My name space
app_name = 'basicapp'
urlpatterns = [
path('', views.ListView.as_view(), name='list'),
path('details', views.DetailView.as_view(), name='details')
]
and my template
{% extends 'basicapp/basicapp_base.html'%}
{% block body_block %}
<div class="jumbotron">
<h1>Welcome to list of all schools</h1>
<ol>
{% for school in schools %}
<h2><li><a href="{{school.id}}">{{school.name}}</a></li></h2>
{% endfor %}
</ol>
{% endblock %}
And i get this error which i don't really understand
Exception Type: ImproperlyConfigured
Exception Value:
ListView is missing a QuerySet. Define ListView.model, ListView.queryset, or override ListView.get_queryset().
Traceback Switch to copy-and-paste view
C:\ProgramData\Miniconda3\lib\site-packages\django\core\handlers\exception.py in inner
response = get_response(request) ...
▶ Local vars
C:\ProgramData\Miniconda3\lib\site-packages\django\core\handlers\base.py in _get_response
response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
C:\ProgramData\Miniconda3\lib\site-packages\django\core\handlers\base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
C:\ProgramData\Miniconda3\lib\site-packages\django\views\generic\base.py in view
return self.dispatch(request, *args, **kwargs) ...
▶ Local vars
C:\ProgramData\Miniconda3\lib\site-packages\django\views\generic\base.py in dispatch
return handler(request, *args, **kwargs) ...
▶ Local vars
C:\ProgramData\Miniconda3\lib\site-packages\django\views\generic\list.py in get
self.object_list = self.get_queryset() ...
▶ Local vars
C:\ProgramData\Miniconda3\lib\site-packages\django\views\generic\list.py in get_queryset
'cls': self.__class__.__name__ ...
▶ Local vars