Use the default DRF WKT serializer for specific serializer class

44 views
Skip to first unread message

Bryce Groff

unread,
Apr 10, 2016, 6:39:46 PM4/10/16
to Django REST Framework GIS
Hello All,

I was wondering if there was a way to use the default DRF WKT serializer for specific parts of my application. The use case that I have is trying to support a legacy API. I have moved my new endpoints to GeoJSON using the drf-gis package, but I want to allow the legacy endpoints to use the WKT as that is what the client is programmed against. I was unable to find any reference to this issue in the readme (sorry if it exists).

Is this feature available?

Thanks,
Bryce

Federico Capoano

unread,
Apr 11, 2016, 8:43:29 AM4/11/16
to Django REST Framework GIS
Hi Bryce,

try removing rest_framework_gis from INSTALLED_APPS and let me know if it works.

We may need to add a new setting that allows to disable implicit remapping of geo fields in this file:

Federico

Bryce Groff

unread,
Apr 11, 2016, 10:30:49 AM4/11/16
to django-rest-...@googlegroups.com
Hey Federico,

Removing the rest_framework_gis would work, however I want GeoJSON for most endpoints, just not all. Allowing an app to be excluded would work well in my case. Would it also be possible to add a field in a serializer's Meta class. Something along the lines of exclude_geojson_fields = ['some_geomtry_field']?

I can take a stab at the app exclude and try and get a PR in the next few days.

Thanks for the quick reply,
Bryce


--
You received this message because you are subscribed to a topic in the Google Groups "Django REST Framework GIS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework-gis/PmtjDiWmaLY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-rest-framew...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nemesis

unread,
Apr 12, 2016, 1:36:40 PM4/12/16
to django-rest-...@googlegroups.com
I don't think what you want it's easily doable.
It's much simpler to disable the automatic mapping and explicitly use the deprecated GeoModelSerializer for the serializers on which you want to enable drf-gis, which probably now we know for sure we should not remove entirely.

Federico
You received this message because you are subscribed to the Google Groups "Django REST Framework GIS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.

Federico Capoano

unread,
Apr 13, 2016, 4:30:10 AM4/13/16
to Django REST Framework GIS
Alternatively, you have to use some sort of explicit WKT field.

Let us know how you solve it, so I can update the documentation to point out the solution.

Federico

Bryce Groff

unread,
Apr 13, 2016, 10:33:38 AM4/13/16
to django-rest-...@googlegroups.com
Hey Federico,

I think I might do the GeoModelSerializer just to get through. An explicit WKT field would seem to be a good option as well. I will have a day or two probably next week to dive into it. I will let you know how it went when I finish.

--
Reply all
Reply to author
Forward
0 new messages