mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-09-16 09:12:29 +03:00
Resource's get_bound_form() populates instance's form on GET
This commit is contained in:
parent
da8187d2c2
commit
d0f758ee2f
|
@ -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'):
|
||||
form_kwargs = {'data': data, 'files': files}
|
||||
# Bound to an existing model instance
|
||||
return form(data, files, instance=self.view.model_instance)
|
||||
else:
|
||||
return form(data, files)
|
||||
if hasattr(self.view, 'model_instance'): form_kwargs['instance'] = self.view.model_instance
|
||||
|
||||
return form()
|
||||
return form(**form_kwargs)
|
||||
|
||||
def url(self, instance):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user