def get_parents(self):
        cache_key = "%s-category-parents-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, self.id)
        parents = cache.get(cache_key)
        if parents is not None:
            return parents

        parents = []
        category = self.parent
        while category is not None:
            parents.append(category)
            category = category.parent

        cache.set(cache_key, parents)
        return parents
Returns all parent categories.
dataset/ETHPy150Open diefenbach/django-lfs/lfs/catalog/models.py/Category.get_parents