Reputation: 3
I have two integer fields in seperate related models (I don't think it should matter whether they are in the same model or not, as long as they can be related?), called x and y, how could I filter() so I only get results where x > y * 90%?
Upvotes: 0
Views: 932
Reputation: 10353
Maybe (if they are not in the same model):
class A(models.Model)
x = ...
b = OneToOne...
class B(models.Model)
y = ....
A.objects.filter(x__gt=F('b.y')*0.9)
Upvotes: 1