1👍
✅
I would simply do this:
def vendors(request):
items = Itemo.objects.all()
var_2 = request.GET.get("q")
if var_2:
items = items.filter(Vendor_Name__icontains=var_2)
return render(request, 'vendor_db/vendors.html', {'items': items})
and in the template you can do.
{% if items %}
... item output ...
{% else %}
No Results Found
{% endif %}
Source:stackexchange.com