此查询在MySQL中返回一个空的QuerySet,但在SQLite中起作用:
commented_this_month = Post.objects.filter(comment__created__month=now.month)
我的模特非常简单:
class Comment(models.Model):
comment = models.TextField()
author = models.ForeignKey(User, on_delete=models.CASCADE)
created = models.DateTimeField(default=timezone.now)
post = models.ForeignKey(Post, on_delete=models.CASCADE)
我有什么遗失的吗?
答案 0 :(得分:0)
我使用mysql_tzinfo_to_sql实用程序生成了mysql.time_zone *表:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql