1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Added a new GeoJSON serialization format for GeoDjango

Thanks Reinout van Rees for the review.
This commit is contained in:
Claude Paroz
2014-11-08 17:08:12 +01:00
parent c5132382f0
commit 35dac5070b
11 changed files with 245 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ class Serializer(PythonSerializer):
"""
internal_use_only = False
def start_serialization(self):
def _init_options(self):
if json.__version__.split('.') >= ['2', '1', '3']:
# Use JS strings to represent Python Decimal instances (ticket #16850)
self.options.update({'use_decimal': False})
@@ -35,6 +35,9 @@ class Serializer(PythonSerializer):
if self.options.get('indent'):
# Prevent trailing spaces
self.json_kwargs['separators'] = (',', ': ')
def start_serialization(self):
self._init_options()
self.stream.write("[")
def end_serialization(self):