Tutorial missing import: Http404

1,097 views
Skip to first unread message

John Matthew Ian Davis

unread,
Apr 10, 2015, 6:06:10 PM4/10/15
to django...@googlegroups.com
obviously one needs to change:

from django.http import HttpResponse,

to

from django.http import HttpResponse, Http404

but that's a speed-bump that should not be in the tutorial.

NameError at /polls/34/

global name 'Http404' is not defined
Request Method: GET
Request URL: http://localhost:8000/polls/34/
Django Version: 1.8
Exception Type: NameError
Exception Value:
global name 'Http404' is not defined
Exception Location: /home/john/Documents/code/python/django/djangostart/polls/views.py in detail, line 19
Python Executable: /usr/bin/python
Python Version: 2.7.6
Python Path:
['/home/john/Documents/code/python/django/djangostart',
 '/usr/local/lib/python2.7/dist-packages/Django-1.8-py2.7.egg',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
Server time: Fri, 10 Apr 2015 21:30:24 +0000

Ramiro Morales

unread,
Apr 10, 2015, 6:33:36 PM4/10/15
to django...@googlegroups.com
On Fri, Apr 10, 2015 at 6:31 PM, John Matthew Ian Davis <johnmatth...@gmail.com> wrote:
obviously one needs to change:

from django.http import HttpResponse,

to

from django.http import HttpResponse, Http404

If you are talking about part 3 of the tutorial then it in fact contains an import of Http404 and it's intrdroduced together with the first piece of code that uses it.

It's right in the views.py snippet located under the "Raising a 404 error" section title: https://docs.djangoproject.com/en/1.8/intro/tutorial03/#raising-a-404-error

Regards,

--
Ramiro Morales
@ramiromorales

John Matthew Ian Davis

unread,
Apr 10, 2015, 11:56:31 PM4/10/15
to django...@googlegroups.com

 You (and the page) are completely correct, and I missed the relevant line, reading through, a half dozen times in a row. Apologies.
Reply all
Reply to author
Forward
0 new messages