diff options
| author | LincolnPuzey <18750802+LincolnPuzey@users.noreply.github.com> | 2026-02-26 03:55:21 +0800 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-25 14:55:47 -0500 |
| commit | 5b7025317fcf817f8d2e72d871dccd437eb4db72 (patch) | |
| tree | b4dc1795ff8dd552a08e83c6987eea3122252314 | |
| parent | 3a04b226edda13499ab61e24c1812114ad309231 (diff) | |
[6.0.x] Fixed #36848 -- Mentioned BadRequest exception in docs/ref/views.txt.
Backport of 4aefc9ea51cc2d78f43b1dc2aa69732e55d18a56 from main.
| -rw-r--r-- | docs/ref/views.txt | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/docs/ref/views.txt b/docs/ref/views.txt index b60ffc2ed8..d7ad83a64a 100644 --- a/docs/ref/views.txt +++ b/docs/ref/views.txt @@ -148,16 +148,20 @@ The 400 (bad request) view .. function:: defaults.bad_request(request, exception, template_name='400.html') -When a :exc:`~django.core.exceptions.SuspiciousOperation` is raised in Django, +Similarly, Django has a view to handle 400 Bad Request errors. + +This view either produces a "Bad Request" message or loads and renders the +template ``400.html`` if you created it in your root template directory. +It returns with status code 400 indicating that the error condition was the +result of a client operation. By default, nothing related to the exception that +triggered the view is passed to the template context, as the exception message +might contain sensitive information like filesystem paths. + +``django.views.defaults.bad_request`` is triggered by a +:exc:`~django.core.exceptions.BadRequest` exception. Also, when a +:exc:`~django.core.exceptions.SuspiciousOperation` is raised in Django, it may be handled by a component of Django (for example resetting the session data). If not specifically handled, Django will consider the current request a -'bad request' instead of a server error. - -``django.views.defaults.bad_request``, is otherwise very similar to the -``server_error`` view, but returns with the status code 400 indicating that -the error condition was the result of a client operation. By default, nothing -related to the exception that triggered the view is passed to the template -context, as the exception message might contain sensitive information like -filesystem paths. +'bad request' instead of a server error, and handle it with ``bad_request``. ``bad_request`` views are also only used when :setting:`DEBUG` is ``False``. |
