开发者

Get entry by week number using Django ORM?

I tried something like:

MyModel.objects.filter(year__week=1)

It doesn't work. For now, I 开发者_StackOverflow中文版calculate the first day and the last day of the week and then use gte and lte, but it's less than efficient given that SQL comes with a Week function.


It seems that django DateField doesn't have week attribute, as weel as date object from Python. They have both year and month and also day, but not week attribute. I guess you need to translate week to day range and file a ticket on django website ;-)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜