Opened 3 years ago

Closed 3 years ago

#18880 closed Bug (invalid)

[Documentation error] Raising error 404 section is wrong

Reported by: devesh.gupta@… Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords: DoesNotExist exception
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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

Change History (1)

comment:1 Changed 3 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

Note: See TracTickets for help on using tickets.
Back to Top