Ticket #16079: handler404.patch
File handler404.patch, 1.3 KB (added by , 13 years ago) |
---|
-
topics/http/urls.txt
257 257 By default, this is ``'django.views.defaults.page_not_found'``. That default 258 258 value should suffice. 259 259 260 You can only set handler404 in the project-level URLconf. Setting it 261 inside an application has no effect. To give a different 404 page for 262 URLs that start with a specific prefix, it is possible to do that by 263 checking the request path inside the ``handler404`` function. For 264 example:: 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 260 273 .. versionchanged:: 1.2 261 274 Previous versions of Django only accepted strings representing import paths. 262 275 … … 272 285 By default, this is ``'django.views.defaults.server_error'``. That default 273 286 value should suffice. 274 287 288 See `handler404`_ for information about how to provide different error 289 pages for a subset of the URLs. 290 275 291 .. versionchanged:: 1.2 276 292 Previous versions of Django only accepted strings representing import paths. 277 293