-
-
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
ListSerializer doesn't handle unique_together constraints #3970
Comments
Note that I've been performing something similar but handled it outside of generic DRF.
I suspect there are some other specific use cases that would prove hard to solve with validators in their current forms. |
Could it be related to the issue I'm having ? I got
in my Model. User is a cms.models.User object. For some reason, Swagger is throwing an error when trying to list available API endpoints
I know Django REST Swagger is not part of that project, but the call is made from Django REST Framework if I understand the stack trace correctly. |
Related: #2996. |
Hey guys, remove UniqueTogetherValidator validator from serializer by adding:
If user will try to create object that breaks unique_together rule, django will throw model level exception.
|
Checklist
master
branch of Django REST framework.As referenced in
#2575
miki725/django-rest-framework-bulk#30
ListSerializer attempts to apply unique together validation on the queryset passed to it, but some part of the code is passed the full queryset, where it attempts to look up attributes on what it expects to be individual instances.
Steps to reproduce
I've modified a test case found in the above links, and run them against master. I'm not sure what the file should be named, and if it follows your quality standards, so I have not submitted a PR with it.
Expected behavior
The code path looks up properties on individual instances in the queryset, is_valid() returns either True or False depending on the actual data, the tests pass.
Actual behavior
The text was updated successfully, but these errors were encountered: