[Answered ]-How to not include an empty string in the icontains condition in model filter?

1👍

You check the target:

if target:
    queryset = MyModel.objects.filter(my_field__icontains=target)
else:
    queryset = MyModel.objects.none()

Leave a comment