Created
March 1, 2016 13:59
-
-
Save AphonicChaos/601435a1ec49149b04b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def some_view(request): | |
form = SomeForm(request.POST) | |
form_json = { | |
name: { | |
"help_text": field.help_text, | |
"initial": field.initial, | |
"label": field.label[:], | |
"max_length": field.max_length, | |
"min_length": field.min_length, | |
"required": field.required, | |
"widget": type(field).__name__, | |
"widget_attrs": field.widget_attrs(field.widget), | |
} for name, field in form.fields.items() } | |
return HttpResponse(json.dumps(form_json, content_type="application/json") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment