title: Django ORM query for a messaging system
body: <p>I have the following models for an internal messaging app:</p>
  
  <pre><code>class MessageThread(models.Model):
      subject = models.CharField(max_length=256, blank=False)
  
  class Message(models.Model):
      thread = models.ForeignKey(MessageThread)
      content = models.CharField(max_length=5000, blank=False)
      timestamp = models.DateTimeField(auto_now_add=True, blank=False)
      sender = models.ForeignKey(User)
  
  class MessageRecipient(models.Model):
      message = models.ForeignKey(Message)
      thread = models.ForeignKey(MessageThread)
      recipient = models.ForeignKey(User)
      status = models.CharField(max_length=20, choices=MESSAGE_STATUS, default="unread")
  </code></pre>
  
  <p>For a given user, to get a list of threads I am doing:</p>
  
  <pre><code>distinct_threads=MessageThread.objects.filter(messagerecipient__recipient=user)
      .order_by('-message__timestamp').distinct()
  </code></pre>
  
  <p>How would I get rid of all threads with a message that contains the status "deleted" in the ORM? (In other words, I want to get a list of all threads without the thread containing a message with the status="deleted".)</p>