I have a Django model TimeThingie
with two TimeField
s called t1
and t2
.
How do I get all TimeThingie
objects where t1 < t2
?
I have a Django model TimeThingie
with two TimeField
s called t1
and t2
.
How do I get all TimeThingie
objects where t1 < t2
?
Use QuerySet.extra()
to add custom fields and conditions to the query.
You can use F() fields to reference other fields on the model. See http://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-reference-fields-on-the-model for how to do it.
F-objects might be what you want.
TimeThingie.objects.filter(t1__lt=F('t2'))