获取周一上午 10 点到 11 点之间的所有交易

Get all transactions on monday between 10 and 11am

我想知道是否可以在事务数据库上使用 Django 来获取在 10 点到 11 点之间的一个(多个)星期一发生的所有事务。

为了完整起见,这里是模型定义:

class P1data(models.Model):
    date_time = models.DateTimeField(auto_now_add=True, db_index=True)
    price = models.DecimalField(max_digits=40, decimal_places=12)
    volume = models.DecimalField(max_digits=40, decimal_places=12)

使用 week_day and hour 查找:

P1data.objects.filter(date_time__week_day=2, date_time__hour__range=(10, 11))

UPDATE:如果 hour 查找不支持 range 然后尝试使用 lte/[=17= 的组合]:

P1data.objects.filter(date_time__week_day=2,
                      date_time__hour__gte=10,
                      date_time__hour__lte=11)