Add on missing values and values_list methods while we're at it, for the same reasons.

This commit is contained in:
Tehom 2018-06-30 02:31:47 -04:00
parent 24bdf124f5
commit c729b6b916

View file

@ -621,7 +621,7 @@ class TypeclassManager(TypedObjectManager):
def annotate(self, *args, **kwargs):
"""
Overload annotate method to first call .all() to filter on typeclass before annotating.
Overload annotate method to filter on typeclass before annotating.
Args:
*args (any): Positional arguments passed along to queryset annotate method.
**kwargs (any): Keyword arguments passed along to queryset annotate method.
@ -631,6 +631,30 @@ class TypeclassManager(TypedObjectManager):
"""
return super(TypeclassManager, self).filter(db_typeclass_path=self.model.path).annotate(*args, **kwargs)
def values(self, *args, **kwargs):
"""
Overload values method to filter on typeclass first.
Args:
*args (any): Positional arguments passed along to values method.
**kwargs (any): Keyword arguments passed along to values method.
Returns:
Queryset of values dictionaries, just filtered by typeclass first.
"""
return super(TypeclassManager, self).filter(db_typeclass_path=self.model.path).values(*args, **kwargs)
def values_list(self, *args, **kwargs):
"""
Overload values method to filter on typeclass first.
Args:
*args (any): Positional arguments passed along to values_list method.
**kwargs (any): Keyword arguments passed along to values_list method.
Returns:
Queryset of value_list tuples, just filtered by typeclass first.
"""
return super(TypeclassManager, self).filter(db_typeclass_path=self.model.path).values_list(*args, **kwargs)
def _get_subclasses(self, cls):
"""
Recursively get all subclasses to a class.