Debug error pages
With DEBUG
on, Django generates fancy debug error pages in two circumstances:
When a
django.http.Http404
exception is raisedWhen any other exception is raised and not handled by the regular view processing code
In the latter case, the debug page contains a tremendous amount of information about the error, the request that caused it, and the environment at the time it occurred. Deciphering this page and making best use of the information it presents will be covered in the next chapter. The debug pages for Http404
exceptions are considerably simpler and will be covered here.
To see examples of the Http404
debug pages, consider the survey_detail
view from Chapter 4:
def survey_detail(request, pk): survey = get_object_or_404(Survey, pk=pk) today = datetime.date.today() if survey.closes < today: return display_completed_survey(request, survey) elif survey.opens > today: raise Http404 else: return display_active_survey(request...