我会收到有关request.user的所有消息 请考虑以下代码:
views.py
conversation = MessageConversation.objects.filter(Q(user=request.user.id) | Q(recipient=request.user)).order_by ('-date_create')
models.py
class MessageConversation(models.Model):
close = models.BooleanField(default=False)
subject = models.CharField(max_length=32)
user = models.IntegerField(max_length=32, null=True, blank=True)
recipient = models.ManyToManyField(User, null=True, blank=True)
我希望显示有关用户连接的所有对话。如果我在ManyToMany关系中有多个实体,则查询会成倍增加。