Fixed #2515 -- Allow passing of options to JSON serializer. Thanks, nesh.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3795 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
96bc9ec79d
commit
d8b84cac91
1
AUTHORS
1
AUTHORS
|
@ -112,6 +112,7 @@ answer newbie questions, and generally made Django that much better:
|
|||
Eric Moritz <http://eric.themoritzfamily.com/>
|
||||
Robin Munn <http://www.geekforgod.com/>
|
||||
Nebojša Dorđević
|
||||
nesh
|
||||
Sam Newman <http://www.magpiebrain.com/>
|
||||
Neal Norwitz <nnorwitz@google.com>
|
||||
oggie rob <oz.robharvey@gmail.com>
|
||||
|
|
|
@ -16,7 +16,7 @@ class Serializer(PythonSerializer):
|
|||
Convert a queryset to JSON.
|
||||
"""
|
||||
def end_serialization(self):
|
||||
simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder)
|
||||
simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder, **self.options)
|
||||
|
||||
def getvalue(self):
|
||||
return self.stream.getvalue()
|
||||
|
|
|
@ -96,6 +96,21 @@ Django "ships" with a few included serializers:
|
|||
.. _json: http://json.org/
|
||||
.. _simplejson: http://undefined.org/python/#simplejson
|
||||
|
||||
Notes For Specific Serialization Formats
|
||||
----------------------------------------
|
||||
|
||||
json
|
||||
~~~~
|
||||
|
||||
If you are using UTF-8 (or any other non-ASCII encoding) data with the JSON
|
||||
serializer, you must pass ``ensure_ascii=False`` as a parameter to the
|
||||
``serialize()`` call. Otherwise the output will not be encoded correctly.
|
||||
|
||||
For example::
|
||||
|
||||
json_serializer = serializers.get_serializer("json")
|
||||
json_serializer.serialize(queryset, ensure_ascii=False, stream=response)
|
||||
|
||||
Writing custom serializers
|
||||
``````````````````````````
|
||||
|
||||
|
|
Loading…
Reference in New Issue