我有两个模型。评论和他的“子评论”:
class Comment(models.Model):
....
author = models.CharField(max_length=80)
published = models.DateTimeField(auto_now_add=True)
email = models.EmailField(blank=True)
url = models.URLField(blank=True)
post = models.ForeignKey(Entry)
subcomments = models.ManyToManyField('Subcomment', blank=True)
....
class Subcomment(models.Model):
....
author = models.CharField(max_length=80)
published = models.DateTimeField(auto_now_add=True)
email = models.EmailField(blank=True)
url = models.URLField(blank=True)
mcomment = models.ForeignKey(Comment)
....
我试图订阅 RSS 来发表评论。我使用以下代码:
class EntryCommentsFeed(Feed):
....
def items(self, obj):
return Comment.not_spam.filter(post=obj).order_by('-published')[:15]
....
但它只返回没有子评论的评论,我不知道如何用他的“子评论”返回评论本身并按日期排序。