diff --git a/django/views/csrf.py b/django/views/csrf.py index 27e7b5ca37..83377b1832 100644 --- a/django/views/csrf.py +++ b/django/views/csrf.py @@ -60,14 +60,14 @@ CSRF_FAILURE_TEMPLATE = """
In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django's + href="https://docs.djangoproject.com/en/{{ docs_version }}/ref/csrf/">Django’s CSRF mechanism has not been used correctly. For POST forms, you need to ensure:
request
to the template's The view function passes a request
to the template’s render
method.You're seeing the help section of this page because you have You’re seeing the help section of this page because you have
{% if request_path %}
The current path, {{ reason }}
- You're seeing this error because you have
- You're seeing this error because you have DEBUG =
+
DEBUG =
True
in your Django settings file. Change that to False
,
and only the initial error message will be displayed. {{ request_path }}
,{% else %}
- The empty path{% endif %} didn't match any of these.
+ The empty path{% endif %} didn’t match any of these.
DEBUG = True
in
+ You’re seeing this error because you have DEBUG = True
in
your Django settings file. Change that to False
, and Django
will display a standard 404 page.
DEBUG = True
in your
+ You’re seeing this error because you have DEBUG = True
in your
Django settings file. Change that to False
, and Django will
display a standard page generated by the handler for this status code.
not-in-urls
, didn't match", status_code=404)
+ self.assertContains(response, 'not-in-urls
, didn’t match', status_code=404)
def test_404_not_in_urls(self):
response = self.client.get('/not-in-urls')
self.assertNotContains(response, "Raised by:", status_code=404)
self.assertContains(response, "Django tried these URL patterns", status_code=404)
- self.assertContains(response, "not-in-urls
, didn't match", status_code=404)
+ self.assertContains(response, 'not-in-urls
, didn’t match', status_code=404)
# Pattern and view name of a RegexURLPattern appear.
self.assertContains(response, r"^regex-post/(?P<pk>[0-9]+)/$", status_code=404)
self.assertContains(response, "[name='regex-post']", status_code=404)
@@ -130,7 +130,7 @@ class DebugViewTests(SimpleTestCase):
@override_settings(ROOT_URLCONF=WithoutEmptyPathUrls)
def test_404_empty_path_not_in_urls(self):
response = self.client.get('/')
- self.assertContains(response, "The empty path didn't match any of these.", status_code=404)
+ self.assertContains(response, 'The empty path didn’t match any of these.', status_code=404)
def test_technical_404(self):
response = self.client.get('/technical404/')