Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.3.X] Fixed #16079: Clarified (for real this time) how handler404 a…

…nd handler500 work, and that they only work in a root URLconf. Backport of [16804] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16805 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2954c36ff7631a0e0180a6f8aa112fe782294d2e 1 parent 5e451b9
James Bennett authored September 11, 2011
18  docs/intro/tutorial03.txt
@@ -357,11 +357,13 @@ the list is empty.
357 357
 Write a 404 (page not found) view
358 358
 =================================
359 359
 
360  
-When you raise :exc:`~django.http.Http404` from within a view, Django will load
361  
-a special view devoted to handling 404 errors. It finds it by looking for the
362  
-variable ``handler404``, which is a string in Python dotted syntax -- the same
363  
-format the normal URLconf callbacks use. A 404 view itself has nothing special:
364  
-It's just a normal view.
  360
+When you raise :exc:`~django.http.Http404` from within a view, Django
  361
+will load a special view devoted to handling 404 errors. It finds it
  362
+by looking for the variable ``handler404`` in your root URLconf (and
  363
+only in your root URLconf; setting ``handler404`` anywhere else will
  364
+have no effect), which is a string in Python dotted syntax -- the same
  365
+format the normal URLconf callbacks use. A 404 view itself has nothing
  366
+special: It's just a normal view.
365 367
 
366 368
 You normally won't have to bother with writing 404 views. By default, URLconfs
367 369
 have the following line up top::
@@ -393,9 +395,9 @@ Four more things to note about 404 views:
393 395
 Write a 500 (server error) view
394 396
 ===============================
395 397
 
396  
-Similarly, URLconfs may define a ``handler500``, which points to a view to call
397  
-in case of server errors. Server errors happen when you have runtime errors in
398  
-view code.
  398
+Similarly, your root URLconf may define a ``handler500``, which points
  399
+to a view to call in case of server errors. Server errors happen when
  400
+you have runtime errors in view code.
399 401
 
400 402
 Use the template system
401 403
 =======================
42  docs/topics/http/urls.txt
@@ -54,6 +54,10 @@ algorithm the system follows to determine which Python code to execute:
54 54
        :class:`~django.http.HttpRequest` as its first argument and any values
55 55
        captured in the regex as remaining arguments.
56 56
 
  57
+    5. If no regex matches, or if an exception is raised during any
  58
+       point in this process, Django invokes an appropriate
  59
+       error-handling view. See `Error handling`_ below.
  60
+
57 61
 Example
58 62
 =======
59 63
 
@@ -246,6 +250,31 @@ The ``prefix`` parameter has the same meaning as the first argument to
246 250
 ``patterns()`` and is only relevant when you're passing a string as the
247 251
 ``view`` parameter.
248 252
 
  253
+include
  254
+-------
  255
+
  256
+.. function:: include(<module or pattern_list>)
  257
+
  258
+A function that takes a full Python import path to another URLconf module that
  259
+should be "included" in this place.
  260
+
  261
+:func:`include` also accepts as an argument an iterable that returns URL
  262
+patterns.
  263
+
  264
+See `Including other URLconfs`_ below.
  265
+
  266
+Error handling
  267
+==============
  268
+
  269
+When Django can't find a regex matching the requested URL, or when an
  270
+exception is raised, Django will invoke an error-handling view. The
  271
+views to use for these cases are specified by two variables which can
  272
+be set in your root URLconf. Setting these variables in any other
  273
+URLconf will have no effect.
  274
+
  275
+See the documentation on :ref:`customizing error views
  276
+<customizing-error-views>` for more details.
  277
+
249 278
 handler404
250 279
 ----------
251 280
 
@@ -275,19 +304,6 @@ value should suffice.
275 304
 .. versionchanged:: 1.2
276 305
     Previous versions of Django only accepted strings representing import paths.
277 306
 
278  
-include
279  
--------
280  
-
281  
-.. function:: include(<module or pattern_list>)
282  
-
283  
-A function that takes a full Python import path to another URLconf module that
284  
-should be "included" in this place.
285  
-
286  
-:func:`include` also accepts as an argument an iterable that returns URL
287  
-patterns.
288  
-
289  
-See `Including other URLconfs`_ below.
290  
-
291 307
 Notes on capturing text in URLs
292 308
 ===============================
293 309
 
2  docs/topics/http/views.txt
@@ -122,6 +122,8 @@ In order to use the ``Http404`` exception to its fullest, you should create a
122 122
 template that is displayed when a 404 error is raised. This template should be
123 123
 called ``404.html`` and located in the top level of your template tree.
124 124
 
  125
+.. _customizing-error-views:
  126
+
125 127
 Customizing error views
126 128
 =======================
127 129
 

0 notes on commit 2954c36

Please sign in to comment.
Something went wrong with that request. Please try again.