Closed Nekmo closed 6 years ago
The similar issue is #1
@Nekmo Hello! DRF describes this case here: http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
Thanks for your quick response! If this report is duplicated then it can be closed.
Would not it be possible to automatically remove the validation if the instance already exists and the unique fields are not edited?
Thank you.
@Nekmo We've implemented a workaround for this case:
@ruscoder Thank you!
@Nekmo Don't forget to wrap save() in the first serializer into transaction.atomic
to avoid partial objects creating when a validation error happens.
I'm not sure about implementing this wrapping inside the library. I'll create an issue about atomic transactions to collect feedback.
Hello, first of all thank you for creating this library. I think it should be included in the core!
I'm having a problem with the nested user serializer. Validation prevents set an existing user on POST method:
My code:
I have investigated the matter a bit and have found a solution: https://medium.com/django-rest-framework/dealing-with-unique-constraints-in-nested-serializers-dade33b831d9
However, drop validation is a very dirty solution. The validation should be removed only if the user already exists.
Thank you.