mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-23 14:40:06 +03:00
Merge eb11dd5803
into 0fc5a49a11
This commit is contained in:
commit
5214e97529
|
@ -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 issubclass(form, forms.ModelForm) and hasattr(self.view, 'model_instance'): form_kwargs['instance'] = self.view.model_instance
|
||||
|
||||
return form()
|
||||
return form(**form_kwargs)
|
||||
|
||||
@property
|
||||
def _model_fields_set(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user