models.py 668 B

1234567891011121314151617181920
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. # Create your models here.
  4. # 聊天记录表
  5. class Message(models.Model):
  6. # 消息id
  7. message_id = models.AutoField(primary_key=True)
  8. # 是否已接收
  9. is_received = models.BooleanField(default=False)
  10. # 消息来源
  11. fromUser = models.ForeignKey(User, on_delete=models.CASCADE, related_name='from_user')
  12. # 消息去向
  13. toUser = models.ForeignKey(User, on_delete=models.CASCADE, related_name='to_user')
  14. # 消息日期
  15. date = models.DateTimeField(auto_now_add=True)
  16. # 消息内容
  17. plaintext = models.CharField(max_length=2048)