Skip to content

Commit

Permalink
Only pass instance to form for PUT and PATCH. Closes #2073.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Nov 18, 2014
1 parent 5e74f02 commit 084354d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rest_framework/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,10 @@ def get_rendered_html_form(self, data, view, method, request):
if existing_serializer is not None:
serializer = existing_serializer
else:
serializer = view.get_serializer(instance=instance, data=data)
if method in ('PUT', 'PATCH'):
serializer = view.get_serializer(instance=instance, data=data)
else:
serializer = view.get_serializer(data=data)
if data is not None:
serializer.is_valid()
form_renderer = self.form_renderer_class()
Expand Down Expand Up @@ -584,7 +587,10 @@ def get_raw_data_form(self, data, view, method, request):
# View has a serializer defined and parser class has a
# corresponding renderer that can be used to render the data.

serializer = view.get_serializer(instance=instance)
if method in ('PUT', 'PATCH'):
serializer = view.get_serializer(instance=instance)
else:
serializer = view.get_serializer()

# Render the raw data content
renderer = renderer_class()
Expand Down

0 comments on commit 084354d

Please sign in to comment.