diff --git a/applications/common/admin.py b/applications/common/admin.py index 47c8b63f9b557fd178b1f77950ec1cff89e6f531..8bc0c671e95f364f063da75ce07eff49ca52ee39 100644 --- a/applications/common/admin.py +++ b/applications/common/admin.py @@ -36,12 +36,12 @@ def make_menu_tree(): if p.enable == 0: continue # 一二级菜单 - if int(p.type) == 0 or int(p.type) == 1: + if int(p.type) in [0,1] and p not in powers: powers.append(p) power_schema = PowerOutSchema(many=True) # 用已继承 ma.ModelSchema 类的自定制类生成序列化类 power_dict = power_schema.dump(powers) # 生成可序列化对象 - power_dict.sort(key=lambda x: x['id'], reverse=True) + power_dict.sort(key=lambda x: (x['parent_id'], x['id']), reverse=True) menu_dict = OrderedDict() for _dict in power_dict: