Reputation: 464
I have table with following structure:
==========================================
itemName minPrice maxPrice curPrice
==========================================
A 10 20 8
B 15 25 12
c 20 30 25
In mysql is like that
select * from Items where curPrice<minPrice
but i want in django which should return like "A,B item name result".
I already tried with filter but i can not get success.
Upvotes: 0
Views: 261
Reputation: 599490
To compare a value in a filter with another field on the model, use F()
objects:
from django.db.models import F
Item.objects.filter(curPrice__lt=F('minprice'))
Upvotes: 1