Skip to content

Commit 5b671cb

Browse files
committed
Fix rendering HTML form when API error raised. Closes #2103.
1 parent d037c53 commit 5b671cb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

rest_framework/renderers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,10 @@ def get_rendered_html_form(self, data, view, method, request):
525525
else:
526526
instance = None
527527

528-
if request.method == method:
528+
# If this is valid serializer data, and the form is for the same
529+
# HTTP method as was used in the request then use the existing
530+
# serializer instance, rather than dynamically creating a new one.
531+
if request.method == method and serializer is not None:
529532
try:
530533
data = request.data
531534
except ParseError:

0 commit comments

Comments
 (0)