Django: form for json

I am trying to serialize my form in json format. My opinion:

form = CSVUploadForm(request.POST, request.FILES) data_to_json={} data_to_json = simplejson.dumps(form.__dict__) return HttpResponse(data_to_json, mimetype='application/json') 

I have an error <class 'django.forms.util.ErrorList'> is not JSON serializable . What to do to handle django forms?

+4
source share
1 answer

You can see the package called django-remote-forms :

A package that allows you to serialize django forms, including fields and widgets, into a Python dictionary for easy conversion to JSON and expose via API

See also:

+5
source

Source: https://habr.com/ru/post/1500045/


All Articles