class Comment(Base): user = models.ForeignKey(‘user.User‘,on_delete=models.CASCADE, related_name=‘user‘) course = models.ForeignKey(‘course.Course‘,on_delete=models.CASCADE,related_name=‘comment‘ ) to_user = models.ForeignKey(‘user.User‘,on_delete=models.CASCADE,related_name=‘to_user‘,nul l=True,blank=True) fid = models.ForeignKey(‘self‘,on_delete=models.CASCADE,null=True,blank=True) content = models.TextField() def __str__(self): return ‘%s--%s‘%(self.user.username,self.content)
comment_list: [ { "id":1, "fid":‘‘, "content":"用户tom第一次评论", "user":"tom", "to_user":"tom" }, { "id":2, "fid":‘1‘, "content":"用户张三回复tom的评论内容", "user":"zhangsan", "to_user":"tom" }, { "id":3, "fid":2, "content":"用户tom又回复了zhangsan的评论", "user":"tom", "to_user":"zhangsan" }, ]
原文:https://www.cnblogs.com/han0911/p/13946756.html