django - How do I JSON serialize a Python dictionary? -
I am trying to create a Django function for some JSON serializing and it is called
HttpResponse def json_response (some): data = serializers.serialize ("json", some) back htmlresponse (data) I'm using Div>
Update: Python now has its JS handler, instead of importing import json Use C> CGG .
The Django Serializer module is designed to sort Django ORM objects. If you want to convert a regular Python dictionary into sign language, then you should use simplicity, which is not already installed in ships with Zeno.
import json def json_response (some): Return HttpResponse Json.dumps (some)) I have an application / javascript content-type header with it I recommend you send back (you can also use the application / Jason, but this will prevent you from debugging your browser):
import json def json_response (some): Return HttpResponse ( Json.dumps (some), content_type = 'application / javascript; charset = utf8')