Reputation: 24621
How to use where > date in django orm ?
It's work:
res = Prog.objects.filter(end = datetime.now()).order_by('-start')
but this not work:
res = Prog.objects.filter(end > datetime.now()).order_by('-start')
Why ?
Upvotes: 0
Views: 122
Reputation: 488394
Read the documentation
:
Greater than.
Example:
Entry.objects.filter(id__gt=4)
SQL equivalent:
SELECT ... WHERE id > 4;
In your case it would be:
res = Prog.objects.filter(end__gt=datetime.now()).order_by('-start')
Upvotes: 6