Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registration_id unique constraint fails on PUT (Update) #270

Closed
mr-const opened this issue Jan 13, 2016 · 1 comment
Closed

registration_id unique constraint fails on PUT (Update) #270

mr-const opened this issue Jan 13, 2016 · 1 comment
Assignees
Milestone

Comments

@mr-const
Copy link

We use GCMDeviceSerializer as nested serializer

class DataSerializer(serializers.ModelSerializer):
    gcm_device = GCMDeviceSerializer(allow_null=True, required=False)

and it always fails validation when we try to update our Data object with message: {"gcm_device":{"registration_id":["This field must be unique."]}}

It seems that following code executes on both create and update calls:

            # Work around an issue with validating the uniqueness of
            # registration ids of up to 4k
            'registration_id': {
                'validators': [
                    UniqueValidator(queryset=GCMDevice.objects.all())
                ]
            }
@jamaalscarlett
Copy link
Member

This appears to be a known issue with writable nested serializers encode/django-rest-framework#2403

@jamaalscarlett jamaalscarlett self-assigned this Jan 15, 2016
jamaalscarlett added a commit to jamaalscarlett/django-push-notifications that referenced this issue Jan 21, 2016
When the serializer is nested the unique validator on registration_id
does not behave correctly.  This is a known issue with DRF
see: encode/django-rest-framework#2403

Added missing allow_null to device_id field

Fixes jazzband#270
jamaalscarlett added a commit to jamaalscarlett/django-push-notifications that referenced this issue Jan 21, 2016
When the serializer is nested the unique validator on registration_id
does not behave correctly.  This is a known issue with DRF
see: encode/django-rest-framework#2403

Added missing allow_null to device_id field

Fixes jazzband#270
jamaalscarlett added a commit to jamaalscarlett/django-push-notifications that referenced this issue Jan 21, 2016
When the serializer is nested the unique validator on registration_id
does not behave correctly.  This is a known issue with DRF
see: encode/django-rest-framework#2403

Added missing allow_null to device_id field

Fixes jazzband#270
jamaalscarlett added a commit to jamaalscarlett/django-push-notifications that referenced this issue Jan 22, 2016
When the serializer is nested the unique validator on registration_id
does not behave correctly.  This is a known issue with DRF
see: encode/django-rest-framework#2403

Added missing allow_null to device_id field

Fixes jazzband#270
@jleclanche jleclanche added this to the 2.0 milestone Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants