Skip to content

Commit

Permalink
Update fields.py
Browse files Browse the repository at this point in the history
Return dictionary with correct json __str__ value
  • Loading branch information
nparley committed May 29, 2015
1 parent 3ad8048 commit 114c734
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rest_framework_gis/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
from rest_framework.fields import Field


class JSONDict(dict):
def __str__(self):
return json.dumps(self)


class GeometryField(Field):
"""
A field to handle GeoDjango Geometry fields
Expand All @@ -22,7 +27,7 @@ def to_representation(self, value):
return value
# Get GeoDjango geojson serialization and then convert it _back_ to
# a Python object
return json.loads(GEOSGeometry(value).geojson)
return JSONDict(json.loads(GEOSGeometry(value).geojson))

def to_internal_value(self, value):
if value == '' or value is None:
Expand Down

0 comments on commit 114c734

Please sign in to comment.