How can I perform a queryset filter on a django model. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I perform a queryset filter on a django model.

I am trying to perform a filter and it keeps giving an error that "Unsupported lookup 'level' for DecimalField or join on the field not permitted." The model is such as: class Item(models.Model): price = models.DecimalField(max_digits=10,decimal_places=2) ....... My views is like this def store(request): min_price= Item.objects.filter(price__level__lte=1000.00) return render(request, 'store/store.html', {'min' : min_price}) Is there anything I am doing wrong?

13th May 2020, 6:17 PM
prime omondi
prime omondi - avatar
3 Answers
0
Try this def get_queryset(self): return Item.objects.filter(price_level__1000.00)
14th May 2020, 6:15 AM
_itsregalo_ke
_itsregalo_ke - avatar
0
The problem there is that you've put two underscores betweeb price and level
14th May 2020, 6:16 AM
_itsregalo_ke
_itsregalo_ke - avatar
0
I have figured out a way to do it. the query is Item.objects.filter(price__lte=1000.00)
14th May 2020, 7:11 AM
prime omondi
prime omondi - avatar