-
-
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
Writable nested serializer error with UniqueTogetherValidator #2380
Comments
The model serializer here is generating a We'll want to look into handling this more gracefully and documenting some of the constraints that unique together validators cannot automatically be applied too. In the immediate case you'll probably want to turn of the default validators by instead specifying...
Then add the validation in explicitly.
You probably want to stop using |
Also an off-topic point...
You've put |
We're missing a feedback on this. I'm going to close it. |
I think this bug is still open. At least in 3.2.4 i got the same error: self <UniqueTogetherValidator(queryset=Foo.objects.all(), fields=('foo', 'ip'))> attrs {'foo': <Foo: foo>, 'ip': OrderedDict([('address', '5.3.2.5')])} |
the OP issue is to my opinion linked to opposite constraints (write unique together with a read only field). |
I don't know if the 'read only' field changes the behavior. I've a unique constraint on two foreign keys, where the second one is an IP address. I needed to add the 'validators=[]" statement to Meta to turn off the validators. In some way the validator cannot handle complex unique_together constraints. For me it is solved using the proposed workaround, but maybe the unique_together in the library should be extended to handle these kind of fields. |
This sounds like a different issue. Would help if you could come with a failing test case |
I'm still experiencing this issue (Django 1.9, DRF 3.3, Python 2.7). I don't have a test case at the moment, but I'll try to post one over the long weekend. |
Encountered this strange error, any idea what i'm missing?
Django Version: 1.7
Python Version: 2.7.3
DRF: 3.0.2
The text was updated successfully, but these errors were encountered: