1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #34830 -- Added request to csrf_failure view's template context.

Co-authored-by: nessita <124304+nessita@users.noreply.github.com>
This commit is contained in:
Prakhar 2023-11-02 15:12:53 +05:30 committed by Natalia
parent 8a28e983df
commit 535f7b5c6c
2 changed files with 5 additions and 0 deletions

View File

@ -64,6 +64,7 @@ def csrf_failure(request, reason="", template_name=CSRF_FAILURE_TEMPLATE_NAME):
"DEBUG": settings.DEBUG,
"docs_version": get_docs_version(),
"more": _("More information is available with DEBUG=True."),
"request": request,
}
try:
t = loader.get_template(template_name)

View File

@ -131,3 +131,7 @@ 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")
def test_csrf_response_has_request_context_processor(self):
response = self.client.post("/")
self.assertIs(response.wsgi_request, response.context.get("request"))