【发布时间】:2018-06-06 09:35:36
【问题描述】:
[
{'month_number':[1,2,3,4,5]},
{'month_number_2':[6,6,8,8,8,10]}
]
class Test(Modelbase):
student_id = models.IntegerField(null=True)
上面是模型,created_at 是获取月份编号的默认字段。
我已经使用下面的查询来过滤数据,但是使用它我们将不得不再次循环以区分不同的月份。
Model.objects.filter(created_at__month__gte=3).values(*['student_id','created_at'])
我们可以一次性使用 Django ORM 做到这一点吗?
【问题讨论】:
标签: django django-orm django-1.9