From 9312e4cedaabcc137dcb7636b271eed630f6d2b6 Mon Sep 17 00:00:00 2001 From: Siarhei Shytsik Date: Tue, 8 Mar 2016 13:35:01 +0300 Subject: [PATCH 1/3] Django 1.9 support --- swampdragon/serializers/model_serializer.py | 9 +++++++-- swampdragon/serializers/object_map.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/swampdragon/serializers/model_serializer.py b/swampdragon/serializers/model_serializer.py index 1ba6609..420e372 100644 --- a/swampdragon/serializers/model_serializer.py +++ b/swampdragon/serializers/model_serializer.py @@ -1,6 +1,11 @@ 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 = None 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..322d1b6 100644 --- a/swampdragon/serializers/object_map.py +++ b/swampdragon/serializers/object_map.py @@ -1,5 +1,11 @@ -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): From 922156ae621096cd955b7aab256186e8954d86ed Mon Sep 17 00:00:00 2001 From: Siarhei Shytsik Date: Tue, 8 Mar 2016 14:53:57 +0300 Subject: [PATCH 2/3] pep-8 changes --- swampdragon/serializers/model_serializer.py | 5 +++-- swampdragon/serializers/object_map.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/swampdragon/serializers/model_serializer.py b/swampdragon/serializers/model_serializer.py index 420e372..48a386c 100644 --- a/swampdragon/serializers/model_serializer.py +++ b/swampdragon/serializers/model_serializer.py @@ -3,8 +3,9 @@ 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 + from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor as \ + ReverseSingleRelatedObjectDescriptor, ReverseManyToOneDescriptor as ForeignRelatedObjectsDescriptor, \ + ManyToManyDescriptor as ManyRelatedObjectsDescriptor ReverseManyRelatedObjectsDescriptor = None from swampdragon.model_tools import get_property, get_model from swampdragon.serializers.field_serializers import serialize_field diff --git a/swampdragon/serializers/object_map.py b/swampdragon/serializers/object_map.py index 322d1b6..df24e4d 100644 --- a/swampdragon/serializers/object_map.py +++ b/swampdragon/serializers/object_map.py @@ -2,9 +2,10 @@ 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 + from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor as \ + ReverseSingleRelatedObjectDescriptor, ReverseOneToOneDescriptor as SingleRelatedObjectDescriptor,\ + ReverseManyToOneDescriptor as ForeignRelatedObjectsDescriptor,\ + ManyToManyDescriptor as ManyRelatedObjectsDescriptor ReverseManyRelatedObjectsDescriptor = None From a933946137a2745dce6c9ae9b9221e8357b9f777 Mon Sep 17 00:00:00 2001 From: Siarhei Shytsik Date: Thu, 10 Mar 2016 08:20:15 +0300 Subject: [PATCH 3/3] Fix in django 1.9 support --- swampdragon/serializers/model_serializer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swampdragon/serializers/model_serializer.py b/swampdragon/serializers/model_serializer.py index 48a386c..8e2544c 100644 --- a/swampdragon/serializers/model_serializer.py +++ b/swampdragon/serializers/model_serializer.py @@ -6,7 +6,7 @@ from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor as \ ReverseSingleRelatedObjectDescriptor, ReverseManyToOneDescriptor as ForeignRelatedObjectsDescriptor, \ ManyToManyDescriptor as ManyRelatedObjectsDescriptor - ReverseManyRelatedObjectsDescriptor = None + 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