[Django]-The QuerySet value for an exact lookup must be limited to one result using slicing. Filter error

45👍

This:

products = Product.objects.filter(category=category, subcategory=subcategory, kind=kind, available=True)

Should be either:

products = Product.objects.filter(category=category, subcategory=subcategory, kind=kind[0], available=True)

if you want to filter based on one kind,

Or:

products = Product.objects.filter(category=category, subcategory=subcategory, kind__in=kind, available=True)

if you want to filter Products on all kind objects returned above.

👤Alex

Leave a comment