1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Catch AttributeError when generating ContentType labels

This commit is contained in:
jeremystretch
2021-04-05 15:11:29 -04:00
parent 19cb575b90
commit 3ad7622bf0

View File

@@ -123,8 +123,11 @@ class ContentTypeChoiceMixin:
super().__init__(queryset, *args, **kwargs)
def label_from_instance(self, obj):
meta = obj.model_class()._meta
return f'{meta.app_config.verbose_name} > {meta.verbose_name}'
try:
meta = obj.model_class()._meta
return f'{meta.app_config.verbose_name} > {meta.verbose_name}'
except AttributeError:
return super().label_from_instance(obj)
class ContentTypeChoiceField(ContentTypeChoiceMixin, forms.ModelChoiceField):