Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category define error #695

Open
jzplyy opened this issue Dec 19, 2023 · 0 comments
Open

Category define error #695

jzplyy opened this issue Dec 19, 2023 · 0 comments

Comments

@jzplyy
Copy link

jzplyy commented Dec 19, 2023

this class method define
categorys.append(child) is error?

 def get_sub_categorys(self):
        """
        获得当前分类目录所有子集
        :return:
        """
        categorys = []
        all_categorys = Category.objects.all()

        def parse(category):
            if category not in categorys:
                categorys.append(category)
            childs = all_categorys.filter(parent_category=category)
            for child in childs:
                if category not in categorys:
                    categorys.append(child)
                parse(child)

        parse(self)
        return categorys
@jzplyy jzplyy changed the title Category模型定义 Category define error Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant