Ticket #16079: handler404.patch

File handler404.patch, 1.3 KB (added by Martin Vilcans <martin@…>, 13 years ago)

Documentation patch

  • topics/http/urls.txt

     
    257257By default, this is ``'django.views.defaults.page_not_found'``. That default
    258258value should suffice.
    259259
     260You can only set handler404 in the project-level URLconf. Setting it
     261inside an application has no effect. To give a different 404 page for
     262URLs that start with a specific prefix, it is possible to do that by
     263checking the request path inside the ``handler404`` function. For
     264example::
     265
     266    def handler404(request):
     267        if request.get_full_path().startswith('/api/'):
     268            # Provide a minimal 404 page for pages inside /api/
     269            return HttpResponseNotFound('404 Not Found\n')
     270        else:
     271            return django.views.defaults.page_not_found(request)
     272
    260273.. versionchanged:: 1.2
    261274    Previous versions of Django only accepted strings representing import paths.
    262275
     
    272285By default, this is ``'django.views.defaults.server_error'``. That default
    273286value should suffice.
    274287
     288See `handler404`_ for information about how to provide different error
     289pages for a subset of the URLs.
     290
    275291.. versionchanged:: 1.2
    276292    Previous versions of Django only accepted strings representing import paths.
    277293
Back to Top