From 084354d3ebf3949f8c1664d68da4a568da0b10fa Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 18 Nov 2014 15:11:40 +0000 Subject: [PATCH] Only pass instance to form for PUT and PATCH. Closes #2073. --- rest_framework/renderers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index eb04e81e1..7c2b51566 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -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()