title: How to I automatically filter out is_deleted records in an associated table in Django?
body: <p>I am using soft deletes on one of my models in Django, and I am overwriting the default manager to always return active records only, using something like:</p>
  
  <pre><code>class ActiveRecordManager(models.Manager):
      def get_queryset(self):
          return super().get_queryset().filter(is_deleted=False)
  
  class Tag(models.Model):
      is_deleted = models.BooleanField(default=False, db_index=True)
      objects = ActiveRecordManager()
  
  class Photo(models.Model):
      tag = models.ForeignKey(Tag, on_delete=models.CASCADE, related_name="photos")
      objects = ActiveRecordManager()
  </code></pre>
  
  <p>All works well. However, when I do:</p>
  
  <pre><code>tag = Tag.objects.get(pk=100)
  </code></pre>
  
  <p>And then I try to get the associated photos:</p>
  
  <pre><code>photos = tag.photos.all()
  </code></pre>
  
  <p>Then I get photos that are deleted. I only want to return objects that are <em>not</em> deleted (so my regular <em>objects</em> list. I was reading about _base_mangers in Django, which seems to control this, but <a href="https://docs.djangoproject.com/en/3.0/topics/db/managers/#django.db.models.Model._base_manager" rel="nofollow noreferrer">the documentation</a> recommends against filtering objects out:</p>
  
  <blockquote>
    <p>If you override the get_queryset() method and filter out any rows,
    Django will return incorrect results. Don’t do that. A manager that
    filters results in get_queryset() is not appropriate for use as a base
    manager.</p>
  </blockquote>
  
  <p>But what I am not clear about is how I <em>am</em> supposed to filter these results. Any thoughts?</p>
  
  <p>UPDATE: </p>
  
  <p>I was asked to explain how this question is different from this one:
  <a href="https://stackoverflow.com/questions/7489635/how-to-use-custom-manager-with-related-objects">How to use custom manager with related objects?</a></p>
  
  <p>In this 8 year old question they mention a deprecated method. That deprecated method is superseded by the method I outline below (base_managers) which according to the documentation I should <em>not</em> use. If people think I should use it, can you please elaborate? </p>