05.评论模块表结构分析

1.评论模块表结构
 
ID
课程---》课程表
发布品论用户---》用户表
品论内容
评论时间
被回复的用户-----》用户表
对哪个品论进行回复的ID-----》当前这个品论表
 
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"
  },
]

 

posted @ 2020-11-07 19:32  深海海胆  阅读(187)  评论(0)    收藏  举报
Live2D