Problem: I've implemented a custom manager for a model with just one custom query set named get_by_tag
and it's working fine if I use it this way:
ViewStatistic.objects.get_by_tag('some-tag-name').filter(user=user_id)
But when I change the order of queries, in this way:
ViewStatistic.objects.filter(user=user_id).get_by_tag('some-tag-name')
it doesn't work! and raises this error:
AttributeError: 'QuerySet' object has no attribute 'get_by_tag'
Am I missing something?! How can I do this in such a order?
P.S: The custom manager is something like this:
class MyCustomManager(models.Manager):
def get_by_tag(self, tag_name):
posts = Post.objects.filter(tags__pk=tag_name)
return super().get_queryset().filter(post__pk__in=posts)