调试告诉我:
comments = Comment.get_for_intention(id)
是:
{QuerySet} 无法获取类 'django.db.models.query.QuerySet' 的代表
评论型号:
class Comment(models.Model):
user = models.ForeignKey(User)
intention = models.ForeignKey(Intention)
text = models.TextField()
created = models.DateTimeField(default=datetime.datetime.now())
@staticmethod
def get_for_intention(intention_id):
return Comment.objects.filter(intention=intention_id)[:10]
我不知道我做错了什么。有人可以给我任何建议吗?