Reputation: 4008
I have a custom QuerySet:
class EntityModelQuerySet(models.query.QuerySet):
def active(self):
return self.filter(is_active=True)
In the model, I sent the QuerySet to work as manager:
class Entity(models.Model):
is_active = models.BooleanField(default=False)
objects = EntityModelQuerySet.as_manager()
In View I try:
Entity.objects.active.filter(is_home=True)
It gives me an error:
'function' object has no attribute 'filter'
Why, how to fix it ?
Upvotes: 0
Views: 70
Reputation: 47364
You need to call active
function to return queryset, just add ()
:
Entity.objects.active().filter(is_home=True)
Upvotes: 2