Answer the question
In order to leave comments, you need to log in
How to get an object by exact occurrence in ManyToManyField?
There is a model:
class Dialog(models.Model):
is_active = models.BooleanField(
verbose_name='Активность', blank=False, default=True)
members = models.ManyToManyField(
"users.User", verbose_name='Участники',
related_name='dialogues')
members__in[...]
, it finds dialogs in which only one of the participants is in the list dialog = Dialog.objects.filter( Q(members__in=[self.request.user,]) & Q(members__in=[another,]))
, also finds extra
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question