Resource's get_bound_form() populates instance's form on GET

This commit is contained in:
Camille Harang 2012-02-10 12:05:54 +01:00
parent da8187d2c2
commit d0f758ee2f

View File

@ -309,14 +309,11 @@ class ModelResource(FormResource):
return None return None
# Instantiate the ModelForm as appropriate # Instantiate the ModelForm as appropriate
if data is not None or files is not None: form_kwargs = {'data': data, 'files': files}
if issubclass(form, forms.ModelForm) and hasattr(self.view, 'model_instance'): # Bound to an existing model instance
# Bound to an existing model instance if hasattr(self.view, 'model_instance'): form_kwargs['instance'] = self.view.model_instance
return form(data, files, instance=self.view.model_instance)
else:
return form(data, files)
return form() return form(**form_kwargs)
def url(self, instance): def url(self, instance):
""" """