From d0f758ee2f9e2deac3821d7bcea327f9929463a0 Mon Sep 17 00:00:00 2001 From: Camille Harang Date: Fri, 10 Feb 2012 12:05:54 +0100 Subject: [PATCH] Resource's get_bound_form() populates instance's form on GET --- djangorestframework/resources.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/djangorestframework/resources.py b/djangorestframework/resources.py index cc338cc05..561289fc0 100644 --- a/djangorestframework/resources.py +++ b/djangorestframework/resources.py @@ -309,14 +309,11 @@ class ModelResource(FormResource): return None # Instantiate the ModelForm as appropriate - 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) + 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 - return form() + return form(**form_kwargs) def url(self, instance): """