I need to offer a from in which a user can manage the permission associated to some Group.
I'd like to use the forms.ModelForm feature which comes from django, but I cannot understand how to modify the queryset over which the field cycles. I've also taken a deep look in contrib.admin and contrib.auth to discover where those forms are generated but cannot find it.
I'm trying not to use a normal modelForm so the precedent settings are already setted.
This is the scenario. I've added 40 (more or less) permissions to my project, all them codename starts with 'xxxxx.', so I'd like to do this:
class PermissionGroup(forms.ModelForm):
#permissions = forms.ModelMultipleChoiceField(queryset = Permission.objects.filter(codename__startswith = 'xxxxx.'), widget=forms.CheckboxSelectMultiple)
class Meta:
model = Group
fields = ('permissions',)
How can I achieve the result? Or how can I bind precedent permission to a normal form.ModelForm?
Thanks in advance!