Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.6.x] A few doc additions for changes from d228c11.

ce0c5c3 from master.
  • Loading branch information...
commit b2876c0c914be0f12b57c7e6e4f6fae671108096 1 parent aef809f
Ramiro Morales authored September 22, 2013
17  docs/ref/urls.txt
@@ -112,6 +112,23 @@ include()
112 112
 
113 113
 See :ref:`including-other-urlconfs` and :ref:`namespaces-and-include`.
114 114
 
  115
+handler400
  116
+----------
  117
+
  118
+.. data:: handler400
  119
+
  120
+.. versionadded:: 1.6
  121
+
  122
+A callable, or a string representing the full Python import path to the view
  123
+that should be called if the HTTP client has sent a request that caused an error
  124
+condition and a response with a status code of 400.
  125
+
  126
+By default, this is ``'django.views.defaults.permission_denied'``. That default
  127
+value should suffice.
  128
+
  129
+See the documentation about :ref:`the 400 (bad request) view
  130
+<http_bad_request_view>` for more information.
  131
+
115 132
 handler403
116 133
 ----------
117 134
 
3  docs/topics/http/urls.txt
@@ -231,7 +231,7 @@ Error handling
231 231
 When Django can't find a regex matching the requested URL, or when an
232 232
 exception is raised, Django will invoke an error-handling view.
233 233
 
234  
-The views to use for these cases are specified by three variables. Their
  234
+The views to use for these cases are specified by four variables. Their
235 235
 default values should suffice for most projects, but further customization is
236 236
 possible by assigning values to them.
237 237
 
@@ -249,6 +249,7 @@ The variables are:
249 249
 * ``handler404`` -- See :data:`django.conf.urls.handler404`.
250 250
 * ``handler500`` -- See :data:`django.conf.urls.handler500`.
251 251
 * ``handler403`` -- See :data:`django.conf.urls.handler403`.
  252
+* ``handler400`` -- See :data:`django.conf.urls.handler400`.
252 253
 
253 254
 .. _urlpatterns-view-prefix:
254 255
 
35  docs/topics/http/views.txt
@@ -150,8 +150,9 @@ The default 404 view will pass one variable to the template: ``request_path``,
150 150
 which is the URL that resulted in the error.
151 151
 
152 152
 The ``page_not_found`` view should suffice for 99% of Web applications, but if
153  
-you want to override it, you can specify ``handler404`` in your root URLconf
154  
-(setting ``handler404`` anywhere else will have no effect), like so::
  153
+you want to override it, you can specify :data:`~django.conf.urls.handler404`
  154
+in your root URLconf (setting ``handler404`` anywhere else will have no
  155
+effect), like so::
155 156
 
156 157
     handler404 = 'mysite.views.my_custom_404_view'
157 158
 
@@ -177,6 +178,8 @@ Three things to note about 404 views:
177 178
 The 500 (server error) view
178 179
 ----------------------------
179 180
 
  181
+.. function:: django.views.defaults.server_error(request, template_name='500.html')
  182
+
180 183
 Similarly, Django executes special-case behavior in the case of runtime errors
181 184
 in view code. If a view results in an exception, Django will, by default, call
182 185
 the view ``django.views.defaults.server_error``, which either produces a very
@@ -187,8 +190,8 @@ The default 500 view passes no variables to the ``500.html`` template and is
187 190
 rendered with an empty ``Context`` to lessen the chance of additional errors.
188 191
 
189 192
 This ``server_error`` view should suffice for 99% of Web applications, but if
190  
-you want to override the view, you can specify ``handler500`` in your URLconf,
191  
-like so::
  193
+you want to override the view, you can specify
  194
+:data:`~django.conf.urls.handler500` in your root URLconf, like so::
192 195
 
193 196
     handler500 = 'mysite.views.my_custom_error_view'
194 197
 
@@ -207,6 +210,8 @@ One thing to note about 500 views:
207 210
 The 403 (HTTP Forbidden) view
208 211
 -----------------------------
209 212
 
  213
+.. function:: django.views.defaults.permission_denied(request, template_name='403.html')
  214
+
210 215
 In the same vein as the 404 and 500 views, Django has a view to handle 403
211 216
 Forbidden errors. If a view results in a 403 exception then Django will, by
212 217
 default, call the view ``django.views.defaults.permission_denied``.
@@ -227,8 +232,8 @@ view you can use code like this::
227 232
         # ...
228 233
 
229 234
 It is possible to override ``django.views.defaults.permission_denied`` in the
230  
-same way you can for the 404 and 500 views by specifying a ``handler403`` in
231  
-your URLconf::
  235
+same way you can for the 404 and 500 views by specifying a
  236
+:data:`~django.conf.urls.handler403` in your root URLconf::
232 237
 
233 238
     handler403 = 'mysite.views.my_custom_permission_denied_view'
234 239
 
@@ -237,18 +242,22 @@ your URLconf::
237 242
 The 400 (bad request) view
238 243
 --------------------------
239 244
 
  245
+.. versionadded:: 1.6
  246
+
  247
+.. function:: django.views.defaults.bad_request(request, template_name='400.html')
  248
+
240 249
 When a :exc:`~django.core.exceptions.SuspiciousOperation` is raised in Django,
241  
-the it may be handled by a component of Django (for example resetting the
242  
-session data). If not specifically handled, Django will consider the current
243  
-request a 'bad request' instead of a server error.
  250
+it may be handled by a component of Django (for example resetting the session
  251
+data). If not specifically handled, Django will consider the current request a
  252
+'bad request' instead of a server error.
244 253
 
245  
-The view ``django.views.defaults.bad_request``, is otherwise very similar to
246  
-the ``server_error`` view, but returns with the status code 400 indicating that
  254
+``django.views.defaults.bad_request``, is otherwise very similar to the
  255
+``server_error`` view, but returns with the status code 400 indicating that
247 256
 the error condition was the result of a client operation.
248 257
 
249  
-Like the ``server_error`` view, the default ``bad_request`` should suffice for
  258
+Like ``server_error``, the default ``bad_request`` should suffice for
250 259
 99% of Web applications, but if you want to override the view, you can specify
251  
-``handler400`` in your URLconf, like so::
  260
+:data:`~django.conf.urls.handler400` in your root URLconf, like so::
252 261
 
253 262
     handler400 = 'mysite.views.my_custom_bad_request_view'
254 263
 

0 notes on commit b2876c0

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