On Tue, Apr 21, 2015 at 4:57 PM, George L. <[email protected]> wrote:
> 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?

Expected result. JSON is text, if it returned a dictionary, as_json()
wouldn't be a good name!

JsonResponse is a util for turning dictionaries into JSON, if you
actually have JSON strings, you could do something like this:

  json_rsp = HttpResponse(frm.as_json(), content_type='application/json')

Cheers

Tom

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CAFHbX1LqCGu8hbCQEMt%2BN6ycLG%3DYS93WUtnzLjRNMXEjxypXEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to