mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #31095 -- Made RelatedManager.set() preserve existing m2m relations with an invalid type.
This commit is contained in:
committed by
Mariusz Felisiak
parent
5a4d7285bd
commit
a3fc24f014
@@ -999,7 +999,8 @@ def create_forward_many_to_many_manager(superclass, rel, reverse):
|
||||
for obj in objs:
|
||||
fk_val = (
|
||||
self.target_field.get_foreign_related_value(obj)[0]
|
||||
if isinstance(obj, self.model) else obj
|
||||
if isinstance(obj, self.model)
|
||||
else self.target_field.get_prep_value(obj)
|
||||
)
|
||||
if fk_val in old_ids:
|
||||
old_ids.remove(fk_val)
|
||||
|
||||
Reference in New Issue
Block a user