so I have this model:
class Message(models.Model):
creator = models.ForeignKey(User, unique=True)
note = models.CharField(max_length=200, blank=True)
recipients = models.ManyToManyField(User, related_name="shared_to")
read = models.ManyToManyField(User, related_name="read", blank=True)
I want to filter on people who are in both recipients and read, currently I'm doing this.
messages = user.shared_to.all()
for message in messages:
if user not in message.read:
do something
I'm sure there is a way to filter this but I can't figure out how.