mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-12-01 05:54:01 +03:00
Avoid unbound form for GET instance
Do not attempt to get an unbound form for an instance using a GET method. This results in the same issue as getting a generic form where an explicit form must be provided for an instance obtained using the GET method.
This commit is contained in:
parent
580031a914
commit
b5f986abdd
|
@ -244,6 +244,9 @@ class DocumentingTemplateRenderer(BaseRenderer):
|
|||
except Exception:
|
||||
form_instance = None
|
||||
|
||||
# Forms for the GET method must be explicit, so do not get an unbound
|
||||
# form nor create a generic form for this instance.
|
||||
if method != 'get':
|
||||
# If we still don't have a form instance then try to get an unbound form
|
||||
if not form_instance:
|
||||
try:
|
||||
|
@ -252,9 +255,8 @@ class DocumentingTemplateRenderer(BaseRenderer):
|
|||
pass
|
||||
|
||||
# If we still don't have a form instance then try to get an unbound form
|
||||
# which can tunnel arbitrary content types. Forms for the GET method
|
||||
# must be explicit, so do not create a generic form.
|
||||
if not form_instance and method != 'get':
|
||||
# which can tunnel arbitrary content types.
|
||||
if not form_instance:
|
||||
form_instance = self._get_generic_content_form(view)
|
||||
|
||||
return form_instance
|
||||
|
|
Loading…
Reference in New Issue
Block a user