mateusz.szulc wrote:
>>From Django Part 3 tutorial:
> "The 404 view is also called if Django doesn't find a match after
> checking every regular expression in the URLconf."
> 
> The 404 default view in django is defined as:
> def page_not_found(request, template_name='404.html'):
> 
> How can I change the value of the template_name parameter?
> 

Well, in your project's base urls.py, put:

handler404 = 'myapp.views.page_not_found'
handler500 = 'myapp.views.server_error'

in your myapp/views.py:

from django.views.defaults import page_not_found as default_page_not_found
from django.views.defaults import server_error as default_server_error

# Use custom 404 and 500 handlers, just to override template names
def page_not_found(request, template_name='tomato404.html.djt'):
    return default_page_not_found(request, template_name=template_name)

def server_error(request, template_name='tomato500.html.djt'):
    return default_server_error(request, template_name=template_name)




--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to