mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
Defer compilation of choices for object_types
This commit is contained in:
parent
5cf8dc44ba
commit
5d08a80c9e
@ -272,15 +272,19 @@ class GroupForm(forms.ModelForm):
|
|||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
def get_object_types_choices():
|
||||||
|
return [
|
||||||
|
(ot.pk, str(ot))
|
||||||
|
for ot in ObjectType.objects.filter(OBJECTPERMISSION_OBJECT_TYPES).order_by('app_label', 'model')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class ObjectPermissionForm(forms.ModelForm):
|
class ObjectPermissionForm(forms.ModelForm):
|
||||||
object_types = ContentTypeMultipleChoiceField(
|
object_types = ContentTypeMultipleChoiceField(
|
||||||
label=_('Object types'),
|
label=_('Object types'),
|
||||||
queryset=ObjectType.objects.all(),
|
queryset=ObjectType.objects.all(),
|
||||||
widget=SplitMultiSelectWidget(
|
widget=SplitMultiSelectWidget(
|
||||||
choices=[
|
choices=get_object_types_choices
|
||||||
(ot.pk, str(ot))
|
|
||||||
for ot in ObjectType.objects.filter(OBJECTPERMISSION_OBJECT_TYPES).order_by('app_label', 'model')
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
help_text=_('Select the types of objects to which the permission will appy.')
|
help_text=_('Select the types of objects to which the permission will appy.')
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user