You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The badge 1235 is removed from the user (which is fine) but also gets deleted from the db.
I think (but I might be wrong) the correct behavior for foreign keys with on_delete != CASCADE, would be to only update the foreignkey and set it to None.
I have a working patch for this, if you're interested I can submit a pull request.
In short, in NestedUpdateMixin.delete_reverse_relations_if_need():
Hi,
I have the following models (simplified for clarity):
And the following serializers:
As you can see a "Badge" can live without a user (hence the SET_NULL on the foreign key).
When I do the following request:
All is fine, the user and badges are created and associated.
However, when I update the user to remove one of its badges:
The badge 1235 is removed from the user (which is fine) but also gets deleted from the db.
I think (but I might be wrong) the correct behavior for foreign keys with on_delete != CASCADE, would be to only update the foreignkey and set it to None.
I have a working patch for this, if you're interested I can submit a pull request.
In short, in
NestedUpdateMixin.delete_reverse_relations_if_need()
:Regards.
The text was updated successfully, but these errors were encountered: