From 507499f32d69314a2d984d163a4cf01df23e9fb6 Mon Sep 17 00:00:00 2001 From: Dan Jacob Date: Thu, 7 Jan 2021 14:00:50 +0200 Subject: [PATCH] Tidy form invalid method --- src/turbo_response/mixins.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/turbo_response/mixins.py b/src/turbo_response/mixins.py index d86f710..4e775b8 100644 --- a/src/turbo_response/mixins.py +++ b/src/turbo_response/mixins.py @@ -96,9 +96,10 @@ class TurboFormMixin: has 422 status on invalid""" def form_invalid(self, form: forms.Form) -> HttpResponse: - response = super().form_invalid(form) - response.status_code = http.HTTPStatus.UNPROCESSABLE_ENTITY - return response + return self.render_to_response( + self.get_context_data(form=form), + status=http.HTTPStatus.UNPROCESSABLE_ENTITY, + ) class TurboFrameResponseMixin: