1👍
✅
If you want to get a Product
queryset you have to filter the Product
objects and filter via the reverse relation for product color:
products = Product.objects.filter(productcolor_set__r__gte=x).distinct()
1👍
You can use the range field lookup:
You can use range anywhere you can use
BETWEEN in SQL — for dates, numbers
and even characters.
your query:
r_range, g_range, b_range = ((3,130),(0,255),(0,255))
products = Product.objects.filter(productcolor_set__r__range=r_range,
productcolor_set__g__range=g_range,
productcolor_set__b__range=b_range).distinct()
- [Answered ]-Email sending from address is gmail with django
- [Answered ]-Checking boxes for items passed through context in Django
- [Answered ]-Script not working outside html body tag
- [Answered ]-How to display latest 5 posts by pub date?
Source:stackexchange.com