models.py 755 B

1234567891011121314151617181920
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. # 好友表
  4. class Friends(models.Model):
  5. # 用户
  6. user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='friends_user')
  7. # 用户好友
  8. friend = models.ForeignKey(User, on_delete=models.CASCADE, related_name='friends_friend')
  9. # 状态码,可以拉黑名单用,为0表示并不是好友,但是对方向自己发送过消息。
  10. status = models.IntegerField(default=1)
  11. # 好友请求表
  12. class FriendRequest(models.Model):
  13. # 请求方
  14. requester = models.ForeignKey(User, on_delete=models.CASCADE, related_name='requester')
  15. # 接收方
  16. receiver = models.ForeignKey(User, on_delete=models.CASCADE, related_name='receiver')