Return early if value is empty
Some checks failed
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled

This commit is contained in:
Brian Tiemann 2025-08-15 13:57:28 -04:00
parent 8ad3eb1ca2
commit 66e0405974

View File

@ -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