Return 200 when viewing the dedicated 404 page
This commit is contained in:
parent
f452f5deed
commit
cd4252cd64
2 changed files with 10 additions and 3 deletions
|
@ -7,10 +7,16 @@ class Error404PageTestCase(TestCase):
|
|||
|
||||
def test_accessible(self) -> None:
|
||||
response = self.client.get(self.url)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
self.assertContains(response, "<h1>There's nothing here!</h1>", html=True)
|
||||
|
||||
def test_actual_404(self) -> None:
|
||||
response = self.client.get("/does-not-exist/")
|
||||
self.assertContains(
|
||||
response, "<h1>There's nothing here!</h1>", html=True, status_code=404
|
||||
)
|
||||
|
||||
def test_queries(self) -> None:
|
||||
with self.assertNumQueries(10):
|
||||
with self.assertNumQueries(8):
|
||||
self.client.get(self.url)
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ class Error404View(TemplateView):
|
|||
template_name = ERROR_404_TEMPLATE_NAME
|
||||
|
||||
def render_to_response(self, context: dict, **response_kwargs: Any) -> HttpResponse:
|
||||
if self.request.resolver_match.url_name != "404":
|
||||
response_kwargs["status"] = 404
|
||||
return super().render_to_response(context, **response_kwargs)
|
||||
|
||||
|
|
Loading…
Reference in a new issue