按日期时间过滤django模型时获取null

时间:2013-09-13 13:33:13

标签: python sql django datetime

我已将日期时间导入为import datetime

我需要在django模型中将按日期时间过滤的数据库值计算为:

def post_left_count(self):

        return self.post_set.filter(expiry_date=datetime.datetime(2013, 10, 27)).count()

它返回0但它应该返回一个值50,这是我的数据库条目。

如果我将此命令运行到我的sql shell中:

select title , expiry_date from tblpost where expiry_date = '2013-10-27 00:00:00';

结果为50行。

我不知道为什么上面的函数返回0而不是50?

0 个答案:

没有答案