mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Use ContentTypeChoiceField for all ContentType fields
This commit is contained in:
@ -21,6 +21,7 @@ from .utils import expand_alphanumeric_pattern, expand_ipaddress_pattern
|
||||
__all__ = (
|
||||
'CommentField',
|
||||
'ContentTypeChoiceField',
|
||||
'ContentTypeMultipleChoiceField',
|
||||
'CSVChoiceField',
|
||||
'CSVContentTypeField',
|
||||
'CSVDataField',
|
||||
@ -114,7 +115,7 @@ class JSONField(_JSONField):
|
||||
return json.dumps(value, sort_keys=True, indent=4)
|
||||
|
||||
|
||||
class ContentTypeChoiceField(forms.ModelChoiceField):
|
||||
class ContentTypeChoiceMixin:
|
||||
|
||||
def __init__(self, queryset, *args, **kwargs):
|
||||
# Order ContentTypes by app_label
|
||||
@ -126,6 +127,14 @@ class ContentTypeChoiceField(forms.ModelChoiceField):
|
||||
return f'{meta.app_config.verbose_name} > {meta.verbose_name}'
|
||||
|
||||
|
||||
class ContentTypeChoiceField(ContentTypeChoiceMixin, forms.ModelChoiceField):
|
||||
pass
|
||||
|
||||
|
||||
class ContentTypeMultipleChoiceField(ContentTypeChoiceMixin, forms.ModelMultipleChoiceField):
|
||||
pass
|
||||
|
||||
|
||||
#
|
||||
# CSV fields
|
||||
#
|
||||
|
Reference in New Issue
Block a user