Django query on model instance's class
I have an abstract base class that is used by various other models. The problem is that I need the same method that runs a query on all instances of those models, and that the manager isn't accessible via model instances. This is the code I ended up using.
def get_related(self, foo):
return self.__class__.objects.filter(bar=foo)
# This is the real code
#def get_translation(self, language):
# return self.__class__.objects.public(language=language).filter(group_id=self. group_id)
0 comments
Reply