Opened 13 years ago
Closed 13 years ago
#18880 closed Bug (invalid)
[Documentation error] Raising error 404 section is wrong
Description ¶
As per the code and text in written in tutorial 3, "Raising error 404": it is using "DoesNotExist" catch the exception.
This will not work, because exception which is raised when accessing a non-existing template is <class 'django.template.base.TemplateDoesNotExist'>
Instead of DoesNotExist, it should be:
def detail(request, poll_id):
try:
p = Poll.objects.get(pk=poll_id)
return render_to_response('polls/detail.html', {'poll': p})
except TemplateDoesNotExist:
raise Http404
Note:
See TracTickets
for help on using tickets.
Of course you have to create the templates before, as described in the previous section. Please use support channel (https://docs.djangoproject.com/en/dev/faq/help/) before creating a ticket.