Django filter events occurring today

前端 未结 6 738
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 09:56

I\'m struggling to logically represent the following in a Django filter. I have an \'event\' model, and a location model, which can be represented as:

class          


        
6条回答
  •  误落风尘
    2020-12-09 10:45

    How about this: pub_date__gte=datetime(2005, 1, 1)? Use _gte and __lte to limit start and end within one day using chaining method.

    Maybe something like self.filter(start__gte=datetime(2005, 1, 1)).filter(end__lte=datetime(2005, 1, 1)). lte stands for less or equal than, gte stands for greater or equal than.

    I find it in django doc.

提交回复
热议问题