makinacorpus / django-geojson

django-geojson is a collection of helpers to (de)serialize (Geo)Django objects into GeoJSON.
GNU Lesser General Public License v3.0
258 stars 70 forks source link

Django 1.10 removes get_all_related_objects and breaks serializer #82

Closed florianm closed 7 years ago

florianm commented 8 years ago

Using django-geojson with Django 1.10 throws "''Options' object has no attribute 'get_all_related_objects'".

Following Django 1.10's migration docs, serializes.pt L313 should probably read

[f for f in MyModel._meta.get_fields() 
  if (f.one_to_many or f.one_to_one) 
  and f.auto_created and not f.concrete]

However, doing so will raise errors on L350, where field.serialize will fail for ForeinKey and OneToOne fields. Removing the if field.serialize conditions then raises 'OneToOneRel' object has no attribute 'rel'.

Where is this method field.serialize supposed to come from?

florianm commented 7 years ago

django-geojson==2.9.1 seems to work now, thanks to serializers.py L 432 ff. - custom get_allrelated* methods honouring Django version. Closing, thanks for the fix!