def get_current_category(self, request):
        last_category = None
        category = None
        product_categories = self.get_categories()
        if len(product_categories) >= 1:
            try:
                if len(product_categories) == 1:
                    category = product_categories[0]
                    return category
                else:
                    last_category = request.session.get("last_category")

                if last_category is None:
                    return product_categories[0]

                category = None
                if last_category in product_categories:
                    category = last_category
                else:
                    children = last_category.get_all_children()
                    for product_category in product_categories:
                        if product_category in children:
                            category = product_category
                            break
                if category is None:
                    category = product_categories[0]
            except IndexError:
                category = None
        request.session["last_category"] = category
        return category
Only load the module if nftables is installed
dataset/ETHPy150Open diefenbach/django-lfs/lfs/catalog/models.py/Product.get_current_category--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/nftables.py/__virtual__