title: Django - combining custom querysets used as managers with abstract class inheritance
body: <p>Basically, I have to achieve two goals in my project that are currently conflicting with each other in terms of implementation.</p>
  
  <p>The goals are:</p>
  
  <ol>
  <li>Enabling chainable filtering for model instances (my_model.objects.custom_filter1().custom_filter2() etc)</li>
  <li>For those tables with <code>is_deleted</code> field, and I want to exclude records marked as deleted, so that I don't have to explicitly filter for deleted records (use <code>my_model.objects.all()</code> instead of <code>my_model.objects.filter(is_deleted = false)</code>)</li>
  </ol>
  
  <p>Currently I have the following code:</p>
  
  <pre><code>class MixinManager(models.Manager): 
      def get_queryset(self):
          try:
              return self.model.MixinQuerySet(self.model).filter(is_deleted=False)
          except FieldError:
              return self.model.MixinQuerySet(self.model)
  
  class BaseMixin(models.Model):
      objects = MixinManager()
  
  class MixinQuerySet(QuerySet):
      pass
      class Meta:
         abstract = True
  
  class DeleteMixin(BaseMixin):
      is_deleted = models.BooleanField(default=False)
  
      class Meta:
          abstract = True
  
  class Sms(DeleteMixin):
      # core fielrds
      # objects = SmsQuerySet.as_manager()
      class Meta:
          managed = False
          db_table = 'sms'
  </code></pre>
  
  <p>However, my first goal becomes seemingly infeasible. Prior to using abstract classes for achieving the second goal, I had the following code 
  to solve the second goal:</p>
  
  <pre><code>class SmsQuerySet(models.query.QuerySet):
      def filter_1(self, user):
          return self.filter(...)
      def filter_2(self, user):
          return self.filter(...)
  
      def filter_3(self, user):
          return self.filter(...)
  
  class Sms(models.Model):
     # core fields
     objects = SmsQuerySet.as_manager()
  </code></pre>
  
  <p>This syntax solved my first goal.</p>
  
  <p><strong>THE QUESTION:</strong></p>
  
  <p>The problem is that I can't combine these two structures into one logic, so that I can write:</p>
  
  <pre><code>sms.objects.filter_1().filter_2().filter_3()
  </code></pre>
  
  <p>so that deleted records are exluded from <code>sms.objects</code>.
  If I uncomment the <code># objects = SmsQuerySet.as_manager()</code> line in the first code snippet, then the <code>objects</code> field of <code>BaseMixin</code> will be ignored and I will end up with deleted records in the final queryset. On the other hand, if I comment the line, than my custom querysets become unreachable.</p>
  
  <p>I hope I succeeded to concisely describe what I am trying to do. Will be very grateful for any hint towards the solution! </p>