views.defaults.bad_request()

defaults.bad_request(request, exception, template_name='400.html')

When a 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 views are also only used when DEBUG is False.

Changed in Django 1.9:

The signature of bad_request() changed in Django 1.9. The function now accepts a second parameter, the exception that triggered the error.

Changed in Django 1.10:

Passing a nonexistent template_name will raise TemplateDoesNotExist.

doc_Django
2016-10-09 18:40:46
Comments
Leave a Comment

Please login to continue.