我正在尝试为我的django项目实现树状注释。每条评论都可以回复,并保存为给定的评论孩子。
comment 1
|- reply 1 to comment 1
|- reply 2 to comment 1
|- reply 3 to comment 1
|- reply 1 to reply 3 to comment 1
|- reply 2 to reply 3 to comment 1
comment 2
|- reply 1 to comment 2
... and so on ...
这是我的模特:
class Comment(models.Model):
author = models.ForeignKey(User)
parent = models.ForeignKey(Comment, blank=True) #
text = models.TextField()
created = models.DateTimeField()
updated = models.DateTimeField(blank=True)
这是要走的路还是重新发明轮子?我敢肯定,这是典型的足够的案例,所以有这样的内置解决方案吗?谢谢。
答案 0 :(得分:4)