save single groups

This commit is contained in:
Laura Klünder 2017-07-13 14:08:05 +02:00
parent d74e4973f9
commit 3f6bb910d8

View file

@ -139,6 +139,7 @@ class EditorFormBase(ModelForm):
if field.many_to_many:
groups = reduce(operator.or_, (set(value) for name, value in self.cleaned_data.items()
if name.startswith('groups_')), set())
groups |= set(value for name, value in self.cleaned_data.items() if name.startswith('group_'))
groups = tuple((int(val) if val.isdigit() else val) for val in groups)
self.instance.groups.set(groups)