summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Hiebert <ryan@ryanhiebert.com>2024-05-18 04:30:12 -0500
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-05-21 11:03:39 +0200
commitc201014e85f321173a018914e148734f29f1e28b (patch)
treea78433d1eb5720de4d322417c037134386872fc0
parent0b33a3abc2ca7d68a24f6d0772bc2b9fa603744e (diff)
Removed hardcoded docs version in csrf template.
-rw-r--r--django/views/templates/csrf_403.html2
-rw-r--r--tests/view_tests/tests/test_csrf.py12
2 files changed, 13 insertions, 1 deletions
diff --git a/django/views/templates/csrf_403.html b/django/views/templates/csrf_403.html
index 42fea9911b..ee81b04bcc 100644
--- a/django/views/templates/csrf_403.html
+++ b/django/views/templates/csrf_403.html
@@ -53,7 +53,7 @@
<li>Your browser is accepting cookies.</li>
<li>The view function passes a <code>request</code> to the template’s <a
- href="https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render"><code>render</code></a>
+ href="https://docs.djangoproject.com/en/{{ docs_version }}/topics/templates/#django.template.backends.base.Template.render"><code>render</code></a>
method.</li>
<li>In the template, there is a <code>{% templatetag openblock %} csrf_token
diff --git a/tests/view_tests/tests/test_csrf.py b/tests/view_tests/tests/test_csrf.py
index af16ffd740..2d530cc586 100644
--- a/tests/view_tests/tests/test_csrf.py
+++ b/tests/view_tests/tests/test_csrf.py
@@ -132,3 +132,15 @@ class CsrfViewTests(SimpleTestCase):
with mock.patch.object(Path, "open") as m:
csrf_failure(mock.MagicMock(), mock.Mock())
m.assert_called_once_with(encoding="utf-8")
+
+ @override_settings(DEBUG=True)
+ @mock.patch("django.views.csrf.get_docs_version", return_value="4.2")
+ def test_doc_links(self, mocked_get_complete_version):
+ response = self.client.post("/")
+ self.assertContains(response, "Forbidden", status_code=403)
+ self.assertNotContains(
+ response, "https://docs.djangoproject.com/en/dev/", status_code=403
+ )
+ self.assertContains(
+ response, "https://docs.djangoproject.com/en/4.2/", status_code=403
+ )