You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi my problem is I can select multiple categories for my item and on my website I have a filter checkbox where the user can check and filter the items based on the categories
On my model I created a category = MultiSelectField(choices=CATEGORY_CHOICES), it works like a charm on django admin. But when it comes to filter on my view I am facing problems in getting the right data returned
I am sending an array ['IT', 'PK', 'CB']
and trying to do like this on my view.py
using
Item.objects.filter(category__icontains=category)
is the closest that I could get from getting my data right
I've already tried using __in, __contains
the problem is I if the user check 3 categories if one product doesnt have one if these 3 it dont retrieve
The text was updated successfully, but these errors were encountered:
@PedroPini how to solve this problem? i'm solving this way :
Item.objects.filter(Q(category__icontains='IT') | Q(category__icontains='PK') | Q(category__icontains='CB'))
Hi my problem is I can select multiple categories for my item and on my website I have a filter checkbox where the user can check and filter the items based on the categories
On my model I created a category = MultiSelectField(choices=CATEGORY_CHOICES), it works like a charm on django admin. But when it comes to filter on my view I am facing problems in getting the right data returned
I am sending an array ['IT', 'PK', 'CB']
and trying to do like this on my view.py
using
Item.objects.filter(category__icontains=category)
is the closest that I could get from getting my data right
I've already tried using __in, __contains
the problem is I if the user check 3 categories if one product doesnt have one if these 3 it dont retrieve
The text was updated successfully, but these errors were encountered: