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/#use-generic-views-less-code-is-better
>  in 
> the Django tutorial and it seems replacing HTTPRequests with GenericViews 
> broke the web server. I followed the instructions and now have this:
>
> 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 <http://localhost:8000/polls/#>
>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\core\handlers\exception.py in 
>    inner
>    1. 
>       
>                   response = get_response(request)
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/#>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\core\handlers\base.py in 
>    _get_response
>    1. 
>       
>                       response = self.process_exception_by_middleware(e, 
> request)
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/#>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\core\handlers\base.py in 
>    _get_response
>    1. 
>       
>                       response = wrapped_callback(request, *callback_args, 
> **callback_kwargs)
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/#>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\views\generic\base.py in view
>    1. 
>       
>                   return self.dispatch(request, *args, **kwargs)
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/#>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\views\generic\base.py in dispatch
>    1. 
>       
>               return handler(request, *args, **kwargs)
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/#>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\views\generic\list.py in get
>    1. 
>       
>               self.object_list = self.get_queryset()
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/#>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\views\generic\list.py in 
>    get_queryset
>    1. 
>       
>                           'cls': self.__class__.__name__
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/#>
>    
> Request informationUSER
>
> admin
> GET
>
> No GET data
> POST
>
> No POST data
>
>
>
>
>
>
> for http://localhost:8000/polls/
>
>
>
>
>
>
>
>
>
>
>
>
>
> but polls.1 works:
>
>
> What's new? Not much
>  Nothing
>  I don't know
>  The best
>
>
>
>
>
>
> but voting yields
>
>
> ValueError at /polls/1/vote/
>
> The view polls.views.vote didn't return an HttpResponse object. It returned 
> None instead.
>
> Request Method: POST
> Request URL: http://localhost:8000/polls/1/vote/
> Django Version: 2.2.4
> Exception Type: ValueError
> Exception Value: 
>
> The view polls.views.vote didn't return an HttpResponse object. It returned 
> None instead.
>
> Exception Location: E:\computer 
> stuff\python\lib\site-packages\django\core\handlers\base.py in 
> _get_response, line 126
> 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:11:31 -0700
> Traceback Switch to copy-and-paste view 
> <http://localhost:8000/polls/1/vote/#>
>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\core\handlers\exception.py in 
>    inner
>    1. 
>       
>                   response = get_response(request)
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/1/vote/#>
>    - E:\computer 
>    stuff\python\lib\site-packages\django\core\handlers\base.py in 
>    _get_response
>    1. 
>       
>                       "returned None instead." % (callback.__module__, 
> view_name)
>       
>       …
>    ▶ Local vars <http://localhost:8000/polls/1/vote/#>
>    
> Request informationUSER
>
> admin
> GET
>
> No GET data
> POST
> VariableValue
> csrfmiddlewaretoken 
>
> 'pLPWGJ7M3I1Idu1wuWYN1sTwdE9cESkJnCgd1jIY1qHc5ebY4sg6hSdNnyFeWOE6'
>
> choice 
>
> '2'
>
>
>
>
> 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+unsubscr...@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.

Reply via email to