Fix push notification registration request

parent a2a93ae3
......@@ -10,6 +10,7 @@ class DeviceSerializer(ModelSerializer):
receive_category = ManyRelatedField(
allow_empty=True,
required=False,
child_relation=PrimaryKeyRelatedField(allow_empty=True,
queryset=Category.objects.all(),
required=False)
......
......@@ -29,7 +29,8 @@ class DeviceViewSet(ModelViewSet):
)
except Device.DoesNotExist:
pass
if len(serializer.validated_data['receive_category']) > 0:
data = serializer.validated_data
if 'receive_category' in data and len(data['receive_category']) > 0:
serializer.save(user=self.request.user, language=language)
else:
categories = [c.pk for c in Category.objects.all()]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment