In this section about 404 of the tutorial part 3, I find this list unclear.
- The 404 view is also called if Django doesn't find a match after checking every regular expression in the URLconf.
- If you don't define your own 404 view -- and simply use the default, which is recommended -- you still have one obligation: To create a 404.html template in the root of your template directory. The default 404 view will use that template for all 404 errors.
- If DEBUG is set to True (in your settings module) then your 404 view will never be used, and the traceback will be displayed instead.
I'd prefer starting with the last item. Also, when DEBUG is set to False and if you didn't create a 404.html file, you get an error 500. I think this should be explained here.
I'd suggest:
- If DEBUG is set to True (in your settings module) then your 404 view will never be used, and the traceback will be displayed instead.
- The 404 view is also called if Django doesn't find a match after checking every regular expression in the URLconf.
- If you don't define your own 404 view -- and simply use the default, which is recommended -- you still have one obligation: To create a 404.html template in the root of your template directory. The default 404 view will use that template for all 404 errors.
- If DEBUG is set to False (in your settings module) and if you didn't create a 404.html file, an Http500 is raised.
BTW I don't like this 500 feature but this is another story. I'd prefer the server to just send a 404 Not Found.