Fall back to parsing request body as JSON for form data
apparently that's what we'll be dealing with from Vue.js AJAX requests?
This commit is contained in:
parent
5c28f10921
commit
c24098a117
|
@ -889,7 +889,18 @@ class Form(object):
|
|||
del self.validated
|
||||
if self.request.method != 'POST':
|
||||
return False
|
||||
|
||||
# we assume data is in the form of POST params
|
||||
controls = self.request.POST.items()
|
||||
|
||||
# but if not, we can try to parse request body as JSON
|
||||
if not controls:
|
||||
try:
|
||||
controls = self.request.json_body.items()
|
||||
except ValueError:
|
||||
# not a valid JSON body, so no data
|
||||
controls = []
|
||||
|
||||
dform = self.make_deform_form()
|
||||
try:
|
||||
self.validated = dform.validate(controls)
|
||||
|
|
Loading…
Reference in a new issue