1👍
✅
You check the target:
if target:
queryset = MyModel.objects.filter(my_field__icontains=target)
else:
queryset = MyModel.objects.none()
Source:stackexchange.com