+ 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?
3 ответов
0
Try this
def get_queryset(self):
return Item.objects.filter(price_level__1000.00)
0
The problem there is that you've put two underscores betweeb price and level
0
I have figured out a way to do it.
the query is
Item.objects.filter(price__lte=1000.00)