Code

Opened 5 years ago

Closed 2 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!

Attachments (0)

Change History (5)

comment:1 Changed 5 years ago by thejaswi_puthraya

  • Component changed from Uncategorized to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Accepted

comment:3 in reply to: ↑ description Changed 4 years ago by rctay

  • Resolution set to worksforme
  • Status changed from new to closed

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 2 years ago by anonymous

  • Easy pickings unset
  • Resolution worksforme deleted
  • Severity set to Normal
  • Status changed from closed to reopened
  • Type set to Uncategorized
  • UI/UX unset
  • Version changed from 1.0 to 1.4-rc-1

comment:5 Changed 2 years ago by ramiro

  • Resolution set to worksforme
  • Status changed from reopened to closed
  • Version changed from 1.4-rc-1 to 1.0

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.