开发者

Django: QuerySet with objects where one time is earlier than another

I have a Django model TimeThingie with two TimeField开发者_如何学JAVAs called t1 and t2.

How do I get all TimeThingie objects where t1 < t2?


F-objects might be what you want.

TimeThingie.objects.filter(t1__lt=F('t2'))


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.


Use QuerySet.extra() to add custom fields and conditions to the query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜