def __init__(self, user, editor, request, *args, **kwargs): self.user = user self.editor = editor self.request = request super(UserGroupsForm, self).__init__(*args, **kwargs) self.old_groups = get_groups(self.user, filter=Group.objects.search(user=editor)) self.old_memberships = get_memberships(self.user, filter=Group.objects.search(user=editor)) self.fields['groups'].initial = self.old_groups self.fields['groups'].choices = group_choices(editor)