Django rest framework中ChatMsg.objects.filter(user=8,touserid=9)的user与touserid如何从html前端里获取的
class ChatMsg(models.Model):
"""
聊天信息
"""
user = models.ForeignKey(User, verbose_name="用户",on_delete=models.CASCADE)
msg = models.TextField('聊天消息',max_length=20000,)
touserid = models.CharField(max_length=32, verbose_name="发给谁的id",)
read = models.BooleanField(verbose_name="是否被读", help_text="是否被读",default=False)
add_time = models.DateTimeField(verbose_name='添加时间', default=datetime.now)
class Meta:
verbose_name = "聊天信息"
verbose_name_plural = "聊天信息"
def __str__(self):
return u'%s' % self.user.id
class ReadMsgView(mixins.DestroyModelMixin,ListModelMixin,viewsets.GenericViewSet)
queryset = ChatMsg.objects.filter(user=8,touserid=9)
serializer_class = ReadMsgSerializer # 序列化验证
添加回答
举报
0/150
提交
取消