mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
Return early if value is empty
This commit is contained in:
parent
8ad3eb1ca2
commit
66e0405974
@ -114,12 +114,12 @@ class CSVMultipleContentTypeField(forms.ModelMultipleChoiceField):
|
|||||||
|
|
||||||
# TODO: Improve validation of selected ContentTypes
|
# TODO: Improve validation of selected ContentTypes
|
||||||
def prepare_value(self, value):
|
def prepare_value(self, value):
|
||||||
|
if not value:
|
||||||
|
return None
|
||||||
if type(value) is str:
|
if type(value) is str:
|
||||||
ct_filter = Q()
|
ct_filter = Q()
|
||||||
for name in value.split(','):
|
for name in value.split(','):
|
||||||
app_label, model = name.split('.')
|
app_label, model = name.split('.')
|
||||||
ct_filter |= Q(app_label=app_label, model=model)
|
ct_filter |= Q(app_label=app_label, model=model)
|
||||||
return list(ContentType.objects.filter(ct_filter).values_list('pk', flat=True))
|
return list(ContentType.objects.filter(ct_filter).values_list('pk', flat=True))
|
||||||
if value:
|
return object_type_identifier(value)
|
||||||
return object_type_identifier(value)
|
|
||||||
return None
|
|
||||||
|
Loading…
Reference in New Issue
Block a user