diff --git a/gas/forms.py b/gas/forms.py index 3fc654a..66f6fce 100644 --- a/gas/forms.py +++ b/gas/forms.py @@ -25,6 +25,7 @@ class UserForm(forms.ModelForm): label=_('roles'), required=False, ) + class Meta: model = User fields = ( @@ -33,8 +34,8 @@ class UserForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - if 'roles' not in self.initial and self.instance.pk is not None: - self.initial['roles'] = self.instance.user_roles.values_list('role', flat=True) + if self.instance.pk is not None: + self.initial['roles'] = list(self.instance.user_roles.values_list('role', flat=True)) def save(self, commit=True): obj = super().save(commit=False)