From 23dcbc1f9ea60c689e6a27acb31ba7657cdfa07a Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 19 May 2020 12:57:18 +0300 Subject: [PATCH] CollectionItem: always run both serializers when serializing. --- django_etesync/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django_etesync/views.py b/django_etesync/views.py index 28dc601..034eaed 100644 --- a/django_etesync/views.py +++ b/django_etesync/views.py @@ -236,9 +236,13 @@ class CollectionItemViewSet(BaseViewSet): items = request.data.get('items') deps = request.data.get('deps', None) + # FIXME: It should just be one serializer serializer = self.get_serializer_class()(data=items, context=self.get_serializer_context(), many=True) deps_serializer = CollectionItemDepSerializer(data=deps, context=self.get_serializer_context(), many=True) - if serializer.is_valid() and (deps is None or deps_serializer.is_valid()): + + ser_valid = serializer.is_valid() + deps_ser_valid = (deps is None or deps_serializer.is_valid()) + if ser_valid and deps_ser_valid: try: with transaction.atomic(): collections = serializer.save(collection=collection_object)