﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3335	Flatpages with DEBUG=False requires 404.html	Rob Hudson <treborhudson@…>	Adrian Holovaty	"While I think it is bad to '''not''' have a 404.html, I think this could be cleaner since it '''does''' work when DEBUG=False.  This could lead to a broken site when it is deployed by simply changing the DEBUG setting, which I think is bad.

If flatpages and DEBUG=False and 404.html doesn't exist it throws the error:

{{{
Traceback (most recent call last):

  File ""/opt/local/lib/python2.4/site-packages/django/core/servers/basehttp.py"", line 272, in run
    self.result = application(self.environ, self.start_response)

  File ""/opt/local/lib/python2.4/site-packages/django/core/servers/basehttp.py"", line 614, in __call__
    return self.application(environ, start_response)

  File ""/opt/local/lib/python2.4/site-packages/django/core/handlers/wsgi.py"", line 189, in __call__
    response = self.get_response(request)

  File ""/opt/local/lib/python2.4/site-packages/django/core/handlers/base.py"", line 103, in get_response
    return callback(request, **param_dict)

  File ""/opt/local/lib/python2.4/site-packages/django/views/defaults.py"", line 78, in page_not_found
    t = loader.get_template(template_name)

  File ""/opt/local/lib/python2.4/site-packages/django/template/loader.py"", line 79, in get_template
    source, origin = find_template_source(template_name)

  File ""/opt/local/lib/python2.4/site-packages/django/template/loader.py"", line 72, in find_template_source
    raise TemplateDoesNotExist, name

TemplateDoesNotExist: 404.html
}}}

When DEBUG=False, get_response in core/handlers/base.py triggers the callback to the handler404 which is 'django.views.defaults.page_not_found' which eventually loads the template 404.html.  If it doesn't exist, you get the error above.

When DEBUG=True, get_response loads the django.views.debug.technical_404_response.

I see two options for a fix (and one isn't really a ""fix"")...

1. Change documentation to say that flatpages require that you have a 404.html template.

2. Fix this so it works the same in both DEBUG states.

If !#2 is the best option, this requires a design decision.

One fix could be to change get_response to know whether flatpages is enabled and switch the way it handles the call to page_not_found.  But that couples the base handler to flatpages which is bad.

Another fix could be to change page_not_found to not try to load the 404.html template just yet if flatpages exists.  But again, this couples flatpages to django/core when it is supposed to be a contrib app.

Not sure what the best answer is."		closed	Contrib apps	dev		wontfix		treborhudson@…	Design decision needed	0	0	0	0	0	0
