From 84a4461ac9440ea58390edf161deb48caf9bf90e Mon Sep 17 00:00:00 2001 From: Camille Harang Date: Fri, 10 Feb 2012 22:40:40 +0100 Subject: [PATCH] Revert "Resource's get_bound_form() populates instance's form on GET" This reverts commit d0f758ee2f9e2deac3821d7bcea327f9929463a0. --- djangorestframework/resources.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/djangorestframework/resources.py b/djangorestframework/resources.py index 561289fc0..cc338cc05 100644 --- a/djangorestframework/resources.py +++ b/djangorestframework/resources.py @@ -309,11 +309,14 @@ class ModelResource(FormResource): return None # Instantiate the ModelForm as appropriate - form_kwargs = {'data': data, 'files': files} - # Bound to an existing model instance - if hasattr(self.view, 'model_instance'): form_kwargs['instance'] = self.view.model_instance + if data is not None or files is not None: + if issubclass(form, forms.ModelForm) and hasattr(self.view, 'model_instance'): + # Bound to an existing model instance + return form(data, files, instance=self.view.model_instance) + else: + return form(data, files) - return form(**form_kwargs) + return form() def url(self, instance): """