[Answered ]-Django custom model manager for derived class – filtering on base class attribute

1πŸ‘

βœ…

The problem is with the .get_queryset(…) method of your ApprovedPubhishedArtcilesManager. You can access the model with:

class ApprovedPublishedArticlesManager(models.Manager):
    def get_queryset(self):
        return self.model.approved_objects.filter(is_published=True)

although it might be better to inherit from AuthoriseableApprovedManager and make use of the base implementation of the .get_queryset(…) method. This is also more robust, since you do not have to take into account for what name that manager will be registered.

Leave a comment