-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Conversation
class Meta: | ||
validators = [<UniqueTogetherValidator(queryset=UniqueTogetherModel.objects.all(), fields=('foreign_key', 'one_to_one'))>] | ||
""") | ||
self.assertEqual(unicode_repr(TestSerializer()), expected) |
There was a problem hiding this comment.
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.
The python 2.7 compatibility put appart, this looks good to me. |
Ok, I think I got it now, thanks for the tip. |
Confused - this is Milestoned as 2.4.6, but a pull request against master? |
@tomchristie my bad |
Perfect. I ensured the test failed without the correction. |
can't create nested serializers for unique_together relations
unique_together
relations.
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). Anextra_kwargs
entry ofrequired=True
is set for the constraint, but that conflicts withread_only=True
set as the nested field'skwargs
.