mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-15 08:12:18 -06:00
Return early if value is empty
This commit is contained in:
@@ -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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user