Opened 8 years ago

Closed 4 years ago

#10934 closed Uncategorized (worksforme)

handler404 needs an example

Reported by: mnieber Owned by: nobody
Component: Documentation Version: 1.0
Severity: Normal Keywords: handler404
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

I'm doing the tutorial and tried to set up my own 404 handler, following the hints in the tutorial.
However, here the tutorial is not clear:

  • where exactly does Django look for the handler404 name?
  • should I assign a new object to django.conf.urls.defaults.handler404, or create the name handler404 inside the views module?
  • I did not create a 404.html, how come Django does not complain about that? (quote: The default 404 view will use that template for all 404 errors.)

An example of setting up your own 404 handler would help a lot (I still have not managed, so now it feels like I missed a point somewhere).
By the way, the tutorial is excellent in all other aspects!

Change History (5)

comment:1 Changed 8 years ago by Thejaswi Puthraya

Component: UncategorizedDocumentation

comment:2 Changed 8 years ago by Chris Beaven

Triage Stage: UnreviewedAccepted

comment:3 in reply to:  description Changed 7 years ago by Tay Ray Chuan

Resolution: worksforme
Status: newclosed

Replying to mnieber:

  • where exactly does Django look for the handler404 name?

According to the third paragraph of http://docs.djangoproject.com/en/dev/topics/http/views/#the-404-page-not-found-view the 404 doc, Django looks in your urls.py.

  • should I assign a new object to django.conf.urls.defaults.handler404, or create the name handler404 inside the views module?

This is also addressed in that same paragraph. You just define a variable handler404 and you're set.

  • I did not create a 404.html, how come Django does not complain about that? (quote: The default 404 view will use that template for all 404 errors.)

AFAIK, django doesn't provide a default 404.html. If you didn't create one, you should get a 'template not found' error - that is, if you trigger a 404, AND disable DEBUG or TEMPLATE_DEBUG in your settings (not sure which).

If this isn't the case, then this is a bug with django's template loading system which should be addressed in a separate ticket.

comment:4 Changed 4 years ago by anonymous

Easy pickings: unset
Resolution: worksforme
Severity: Normal
Status: closedreopened
Type: Uncategorized
UI/UX: unset
Version: 1.01.4-rc-1

comment:5 Changed 4 years ago by Ramiro Morales

Resolution: worksforme
Status: reopenedclosed
Version: 1.4-rc-11.0
Note: See TracTickets for help on using tickets.
Back to Top