mjumbewu/django-rest-framework-gis — pull request #1 by batpad (2013-10-21 14:10:53+00:00)
Title: Bugfixes for geometry field name and invalid geojson

Hi,

(thanks for the project)

I had an issue because my geometry field name was called 'point' and not 'geometry', and there was a place in renderers.py where a check for the string 'geometry' was hard-coded. I fixed that, plus added a setting to specify the DEFAULT_GEOMETRY_FIELD in settings.py. Not sure if the setting name could be better namespaced, have added a question in the code.

There was a minor documentation bug where the docs said you can specify a string for an attribute called 'geometry_field' on the view - this should have been 'geometry_field_name'.

Also, I was getting invalid geojson generated by the GeoJSON renderer since it was "double encoding" the geometry json - i.e. getting a json string back from the GEOS object, and then the outer dict being JSON encoded again. I fixed this by doing a json.loads() on the string returned from geometry.json. This seems a bit non-optimal as it is going from python object -> string -> python object -> string, which seems unnecessary, but not sure how to directly get a dict representation of the json object using GEOS. Please improve that if there is a way, but this fixed the invalid geojson and works for me.

Would be great if you could find the time to merge this in - I like the simple way you're doing this and it's a useful project. Let me also know if there's anything else I can do to help.

Thanks.