Skip to content

Conversation

@sheppard
Copy link
Contributor

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.

Copy link
Contributor

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 https://github.com/sheppard/django-rest-framework/blob/read-only-nested/tests/test_model_serializer.py#L172 for example.

@xordoquy
Copy link
Contributor

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
@sheppard
Copy link
Contributor Author

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

@lovelydinosaur
Copy link
Contributor

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
@xordoquy
Copy link
Contributor

@tomchristie my bad

@xordoquy
Copy link
Contributor

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants