django-geojson
django-geojson copied to clipboard
Problem serializing a model class with a foreign field
Hello,
I'm struggling with a problem using this plugin, serializing to GeoJSON a simple model class (call it A) with a Polygon.
The problem is another model class (call it B) contains a foreign key to A, and the serializer throws an error, because it tries to find one of the B fields in A. Of course, it isn't found.
May it be a bug on the serializer?
Extended information about the problem here
It looks like a bug indeed. You can try (temporarly) to specify explicitly the list of properties fields.
Thanks for your response. I finally could solve it by preventing Django to create backwards relation between ROI and Series.
class Series(gismodels.Model): # Prevents django to create a backwards relation between ROI and Series roi = models.ForeignKey(ROI, related_name='+') indicator = models.ForeignKey(Indicator)
I hope it helps.