mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-23 22:49:50 +03:00
Merge eb11dd5803
into 0fc5a49a11
This commit is contained in:
commit
5214e97529
|
@ -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 issubclass(form, forms.ModelForm) and 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)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _model_fields_set(self):
|
def _model_fields_set(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user