diff --git a/swampdragon/serializers/model_serializer.py b/swampdragon/serializers/model_serializer.py index 1ba6609..8e2544c 100644 --- a/swampdragon/serializers/model_serializer.py +++ b/swampdragon/serializers/model_serializer.py @@ -1,6 +1,12 @@ from django.core.exceptions import ValidationError -from django.db.models.fields.related import ReverseSingleRelatedObjectDescriptor, ForeignRelatedObjectsDescriptor, \ - ReverseManyRelatedObjectsDescriptor, ManyRelatedObjectsDescriptor +try: + from django.db.models.fields.related import ReverseSingleRelatedObjectDescriptor, ForeignRelatedObjectsDescriptor, \ + ReverseManyRelatedObjectsDescriptor, ManyRelatedObjectsDescriptor +except ImportError: + from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor as \ + ReverseSingleRelatedObjectDescriptor, ReverseManyToOneDescriptor as ForeignRelatedObjectsDescriptor, \ + ManyToManyDescriptor as ManyRelatedObjectsDescriptor + ReverseManyRelatedObjectsDescriptor = ForeignRelatedObjectsDescriptor from swampdragon.model_tools import get_property, get_model from swampdragon.serializers.field_serializers import serialize_field from swampdragon.serializers.object_map import get_object_map diff --git a/swampdragon/serializers/object_map.py b/swampdragon/serializers/object_map.py index 72bb9e2..df24e4d 100644 --- a/swampdragon/serializers/object_map.py +++ b/swampdragon/serializers/object_map.py @@ -1,5 +1,12 @@ -from django.db.models.fields.related import ReverseSingleRelatedObjectDescriptor, SingleRelatedObjectDescriptor, \ - ForeignRelatedObjectsDescriptor, ManyRelatedObjectsDescriptor, ReverseManyRelatedObjectsDescriptor +try: + from django.db.models.fields.related import ReverseSingleRelatedObjectDescriptor, SingleRelatedObjectDescriptor, \ + ForeignRelatedObjectsDescriptor, ManyRelatedObjectsDescriptor, ReverseManyRelatedObjectsDescriptor +except ImportError: + from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor as \ + ReverseSingleRelatedObjectDescriptor, ReverseOneToOneDescriptor as SingleRelatedObjectDescriptor,\ + ReverseManyToOneDescriptor as ForeignRelatedObjectsDescriptor,\ + ManyToManyDescriptor as ManyRelatedObjectsDescriptor + ReverseManyRelatedObjectsDescriptor = None def _construct_graph(parent_type, child_type, via, is_collection, property_name):