class IndexView(generic.ListView): template_name = 'polls/index.html' context_object_name = 'latest_question_list' def get_queryset(self): """Return the last five published questions.""" return Question.objects.order_by('-pub_date')[:5]
the def get_queryset(self): function is missing. check the indendation as well. always produce the code snippet.
On Friday, November 1, 2019 at 5:19:29 PM UTC+5:30, Mike Starr wrote:
Hi! There's a lot of error message to copy and paste so please request what you would like to see specifically. I am at https://docs.djangoproject.com/en/2.2/intro/tutorial04/# in the Django tutorial and it seems replacing HTTPRequests with GenericViews broke the web server. I followed the instructions and now have this:use-generic-views-less-code- is-better ImproperlyConfigured at /polls/
IndexView is missing a QuerySet. Define IndexView.model, IndexView.queryset, or override IndexView.get_queryset().
Request Method: GET Request URL: http://localhost:8000/polls/ Django Version: 2.2.4 Exception Type: ImproperlyConfigured Exception Value: IndexView is missing a QuerySet. Define IndexView.model, IndexView.queryset, or override IndexView.get_queryset().Exception Location: E:\computer stuff\python\lib\site- packages\django\views\generic\ list.py in get_queryset, line 39 Python Executable: E:\computer stuff\python\python.exe Python Version: 3.7.3 Python Path: ['E:\\computer stuff\\python\\Django\\mysite', 'E:\\computer stuff\\python', 'E:\\computer stuff\\python\\Lib', 'E:\\computer stuff\\python\\Django\\mysite' , 'E:\\computer stuff\\python\\python37.zip', 'E:\\computer stuff\\python\\DLLs', 'E:\\computer stuff\\python\\lib\\site- packages', 'E:\\computer stuff\\python\\lib\\site- packages\\scrapy-1.5.0-py3.7. egg', 'E:\\computer ' 'stuff\\python\\lib\\site- packages\\service_identity-18. 1.0-py3.7.egg', 'E:\\computer stuff\\python\\lib\\site- packages\\pydispatcher-2.0.5- py3.7.egg', 'E:\\computer stuff\\python\\lib\\site- packages\\parsel-1.5.1-py3.7. egg', 'E:\\computer stuff\\python\\lib\\site- packages\\six-1.12.0-py3.7. egg', 'E:\\computer stuff\\python\\lib\\site- packages\\cssselect-1.0.3-py3. 7.egg', 'E:\\computer stuff\\python\\lib\\site- packages\\pyopenssl-19.0.0- py3.7.egg', 'E:\\computer ' 'stuff\\python\\lib\\site- packages\\lxml-4.3.4-py3.7- win-amd64.egg', 'E:\\computer stuff\\python\\lib\\site- packages\\queuelib-1.5.0-py3. 7.egg', 'E:\\computer stuff\\python\\lib\\site- packages\\w3lib-1.20.0-py3.7. egg', 'E:\\computer ' 'stuff\\python\\lib\\site- packages\\pyasn1_modules-0.2. 5-py3.7.egg', 'E:\\computer stuff\\python\\lib\\site- packages\\win32', 'E:\\computer stuff\\python\\lib\\site- packages\\win32\\lib', 'E:\\computer stuff\\python\\lib\\site- packages\\Pythonwin'] Server time: Fri, 1 Nov 2019 01:03:42 -0700 Traceback Switch to copy-and-paste view
E:\computer stuff\python\lib\site-
inpackages\django\core\handlers\ exception.py inner
E:\computer stuff\python\lib\site-
inpackages\django\core\handlers\ base.py _get_response
E:\computer stuff\python\lib\site-
inpackages\django\core\handlers\ base.py _get_response
E:\computer stuff\python\lib\site-
inpackages\django\views\generic\ base.py view
E:\computer stuff\python\lib\site-
inpackages\django\views\generic\ base.py dispatch
E:\computer stuff\python\lib\site-
inpackages\django\views\generic\ list.py get
E:\computer stuff\python\lib\site-
inpackages\django\views\generic\ list.py get_queryset
Request information
USER
admin
GET
No GET data
POST
No POST data
but polls.1 works:What's new?
Request information
USER
admin
GET
No GET data
POST
Variable Value csrfmiddlewaretoken choice Okay. So. I'm going to study this tutorial and code and see if I can solve the problem myself. If anyone has any suggestions I'll be checking back daily, so ti's much appreciated in advance.Thank you!
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/88b426db-98f0-40ae-95cf-65d620cd312f%40googlegroups.com.
No comments:
Post a Comment