Only pass instance to form for PUT and PATCH. Closes #2073.

This commit is contained in:
Tom Christie 2014-11-18 15:11:40 +00:00
parent 5e74f02d61
commit 084354d3eb

View File

@ -547,7 +547,10 @@ class BrowsableAPIRenderer(BaseRenderer):
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()
@ -584,7 +587,10 @@ class BrowsableAPIRenderer(BaseRenderer):
# 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()