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:
Sean C. Farley 2012-04-10 12:23:06 -04:00
parent 580031a914
commit b5f986abdd

View File

@ -244,18 +244,20 @@ class DocumentingTemplateRenderer(BaseRenderer):
except Exception: except Exception:
form_instance = None form_instance = None
# If we still don't have a form instance then try to get an unbound form # Forms for the GET method must be explicit, so do not get an unbound
if not form_instance: # form nor create a generic form for this instance.
try: if method != 'get':
form_instance = view.get_bound_form(method=method) # If we still don't have a form instance then try to get an unbound form
except Exception: if not form_instance:
pass try:
form_instance = view.get_bound_form(method=method)
except Exception:
pass
# If we still don't have a form instance then try to get an unbound form # 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 # which can tunnel arbitrary content types.
# must be explicit, so do not create a generic form. if not form_instance:
if not form_instance and method != 'get': form_instance = self._get_generic_content_form(view)
form_instance = self._get_generic_content_form(view)
return form_instance return form_instance