diff --git a/tailbone/forms/core.py b/tailbone/forms/core.py index 6762b79b..84169a06 100644 --- a/tailbone/forms/core.py +++ b/tailbone/forms/core.py @@ -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)