diff --git a/kfet/forms.py b/kfet/forms.py index 6ef3aefb..7bafbdd7 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -136,6 +136,8 @@ class UserGroupForm(forms.ModelForm): def clean_groups(self): kfet_groups = self.cleaned_data.get('groups') + if self.instance.pk is None: + return kfet_groups other_groups = self.instance.groups.exclude(name__icontains='K-FĂȘt') return list(kfet_groups) + list(other_groups) @@ -173,6 +175,8 @@ class GroupForm(forms.ModelForm): # other_groups = self.instance.permissions.difference( # self.fields['permissions'].queryset # ) + if self.instance.pk is None: + return kfet_perms other_perms = self.instance.permissions.exclude( pk__in=[p.pk for p in self.fields['permissions'].queryset], )