Commit 48c16aeb authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

Merge branch 'fix-serializer-nestedfield' into 'master'

fix: serializer can't bypass manager for m2m

See merge request !112
parents a5d4899d 40a84b85
Pipeline #6768 passed with stage
in 1 minute and 21 seconds
......@@ -661,12 +661,12 @@ class LDPSerializer(HyperlinkedModelSerializer):
item_pk_to_keep = list(
map(lambda e: getattr(e, slug_field), filter(lambda x: hasattr(x, slug_field), data)))
for item in list(manager.all()):
if not str(getattr(item, slug_field)) in item_pk_to_keep:
if getattr(manager, 'through', None) is None:
if getattr(manager, 'through', None) is None:
for item in list(manager.all()):
if not str(getattr(item, slug_field)) in item_pk_to_keep:
item.delete()
else:
manager.remove(item)
else:
manager.clear()
for item in data:
if not isinstance(item, dict):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment