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

Fix nested serializers with unique_together relations. #2975

merged 4 commits into from Jun 1, 2015


Copy link

I came across an unexpected issue when trying to create a read-only nested serializer for a related field that's part of a unique_together constraint (in vera). An extra_kwargs entry of required=True is set for the constraint, but that conflicts with read_only=True set as the nested field's kwargs.

class Meta:
validators = [<UniqueTogetherValidator(queryset=UniqueTogetherModel.objects.all(), fields=('foreign_key', 'one_to_one'))>]
self.assertEqual(unicode_repr(TestSerializer()), expected)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll likely want a slightly different representation for python 2.7.
See for example.

Copy link

The python 2.7 compatibility put appart, this looks good to me.

@xordoquy xordoquy added the Bug label May 28, 2015
@xordoquy xordoquy added this to the 2.4.6 Release milestone May 28, 2015
Copy link
Contributor Author

Ok, I think I got it now, thanks for the tip.

Copy link

Confused - this is Milestoned as 2.4.6, but a pull request against master?

@xordoquy xordoquy modified the milestones: 3.1.3 Release, 2.4.6 Release May 28, 2015
Copy link

@tomchristie my bad

Copy link

xordoquy commented Jun 1, 2015

Perfect. I ensured the test failed without the correction.
Thanks for the fix.

xordoquy added a commit that referenced this pull request Jun 1, 2015
can't create nested serializers for unique_together relations
@xordoquy xordoquy merged commit e3f856f into encode:master Jun 1, 2015
@xordoquy xordoquy changed the title can't create nested serializers for unique_together relations Fix nested serializers with unique_together relations. Jun 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants