Reputation: 2784
In a view I want to get a queryset of values where only the records that have the value of field current_num lesser than current_tot are displayed:
I've tried without success:
qs = qs.filter( F('current_tot')!=F('current_num'))
If lookup for the less than equal, it works:
qs = qs.filter( current_num__lte=F('current_tot'))
If lookup for less than, no result are shown:
qs = qs.filter( current_num__lte=F('current_tot'))
Upvotes: 0
Views: 202
Reputation: 317
You cannot use F on the left side of the equality. To get what you want, use exclude instead of filter :
qs = qs.exclude(current_tot = F('current_num'))
Upvotes: 1