-
Notifications
You must be signed in to change notification settings - Fork 116
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
OneToOne field partial_update with unique tel get unique error. #34
Comments
@yinkanghong Hello! I'm not sure, but it could be possibly fixed in 4.0.2. It will be great if you can check your code with the latest version of the package and leave your feedback. |
My drf-nested-serializer version is 0.4.1,I updated it to 0.4.2 which is latest version now,and this issue still exist.I will try to write a PR this week. |
I find this is a issue for DRF(issue2403、issue2996),In DRF
,when use First way is convert id/pk to instance:
Second way is change the queryset to exclued the pk:
Third way is convert id/pk to instance in WritableNestedModelSerializer:
Third way can't used for I think all of this there solutions is not beautiful enough to write a PR,so i will close this issue. Thank for this good library, |
models.py
:serializers.py
:tests.py
:when I run
test_staff_update
which update nested user with same tel,I get the errordata": { "user": { "tel": [ "The number is registered." ] }
, I know when usepartial_update
method you shouldn't pass the data do not need change,but i don't want do it in front end which useVUE
.And I know this problem is cause by when get child fielduser
,DRF don't pass instance kwargs to it.So i change myStaffModifySerializer
to:the king mind is replace field
user(StaffUserCreateSerializer(partial=True))
to new fielduser(StaffUserCreateSerializer(instance=User_by_id, partial=True))
, I want to witre it insideWritableNestedModelSerializer
but get error when use nestedmany_to_many
,when I‘m free,I will try to write PR.The text was updated successfully, but these errors were encountered: