Skip to content

Commit

Permalink
Removed hardcoded docs version in csrf template.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhiebert authored and sarahboyce committed May 21, 2024
1 parent 0b33a3a commit c201014
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/views/templates/csrf_403.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2>Help</h2>
<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
Expand Down
12 changes: 12 additions & 0 deletions tests/view_tests/tests/test_csrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,15 @@ def test_template_encoding(self):
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
)

0 comments on commit c201014

Please sign in to comment.