【发布时间】:2018-06-17 20:05:34
【问题描述】:
此查询在 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)
我有什么遗漏吗?
【问题讨论】:
标签: mysql django django-orm