-
-
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 in UniqueTogetherValidator to allow it to handle querysets #2575
Conversation
this is especially important when using a serializer with many=True and the model having unique multiple constrains
Could we get this broken down into a simple example case? |
When a model has a |
Serializer level validators should absolutely apply per-instance, not ever at the queryset level. |
Im not sure if this issue can be easily demonstrated in DRF by itself since
The issue might be in DRF-bulk, specifically in EDIT: just realized that |
Shouldn't need to if this is occuring during validation... it'll be triggered by "is_valid()" - you won't need to call ".save()" |
Here is example reproducing the error using vanilla DRF. you can disregard my morning comment dealing with DRF-bulk. https://gist.github.com/miki725/1513401315f5b0fec670 In the example I am using a sample Django app from DRF-bulk tests but all information is enclosed so you should be able to reproduce it as well. |
So again, this pull request won't be quite the right approach. |
Closing based on previous comment. Very happy to discuss this in more fully as an issue if desired. |
Thanks for feedback. When Ill have a chance, Ill try to implement your approach. |
@tomchristie seems like the validator still isn't applied per item. Should I create an issue for this or I'm wrong? |
@sassanh as per comments here you may open a new issue to discuss that. |
this is especially important when using a serializer with
many=True
and the model having unique multiple constrainsexample failure can be found at miki725/django-rest-framework-bulk#30
TODO