Skip to content

Commit

Permalink
Fix django-json-api#784 Clear m2m relationships instead of deleting t…
Browse files Browse the repository at this point in the history
…hem during PATCH

Calling PATCH on an M2M RelationshipView when there were already some relationships was breaking. This was because the related objects were being deleted instead of just clearing the relationship and starting afresh.
  • Loading branch information
rohithpr committed May 14, 2020
1 parent 2adfb5b commit 6deae03
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rest_framework_json_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def remove_relationships(self, instance_manager, field):
setattr(obj, field_object.name, None)
obj.save()
else:
instance_manager.all().delete()
instance_manager.clear()

return instance_manager

Expand Down

0 comments on commit 6deae03

Please sign in to comment.