I have two django managers
class VoteManager(model.Manager):
def all_with_vote_info(self):
qs = super(VoteManager, self).get_query_set()
qs = qs.annotate(score=Sum('votes__score', distinct=True))
return qs
....
class SoftDeleteManager(models.Manager):
def all_active(self):
qs = super(SoftDeleteManager, self).get_query_set()
qs = qs.filter(time_deleted=None)
return qs
....
How can I chain queryset results from VoteManager.all_with_vote_info, SoftDeleteManager.all_active, and any arbitrary number of manager methods?
Found a solution: PassThroughManager
https://django-model-utils.readthedocs.org/en/latest/managers.html#passthroughmanager
Update:
PassThroughManager has been deprecated, use Django’s built-in QuerySet.as_manager() and/or Manager.from_queryset() utilities instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With