Tuesday, April 21, 2015

form.errors.as_json() returns a str - Django 1.8

I'm trying to return errors to an ajax call but as_json() form method generates a string of a dict instead of a dict. JsonResponse accepts only dicts and if I set safe=False, JsonResponse tries to serialize the data as a string, which results in a corrupted data. 

Is this a bug or expected result?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2f81f356-cb5d-47f1-a3dd-c8fc21a66bea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment