前端資料的結構由後臺查詢後構造結構透過雙層for取得結果
html
{% for item in questset %}
{{item.id}}
{{item.name}}
{% for node in questset.childent %}
{{node.id}}
{{node.name}}
後臺
def role_test(request):
#問題:從資料庫中獲取所有的許可權
permission_queryset = models. Permission.objects.all()
{1:{
'title':'賬單列表',"url:/payment/1ist/,'name':payment _list',
children:[
{'title':'刪除賬單','url':'/payment/list/','name':'payment_list'),
{'title':'編輯賬單','url':'/paynent/list/','name':'payment_list'},
{'title':'新增賬單','url':'/payment/list/','name':'payment_list'},
],
2:{
'title':'客戶列表','url': '/payment/list/''name': 'payment_list',
children:[
{'title':'下載客戶模板','url':'/payment/list/','name':'payment_list'},
{'title':'下載客戶模板','url':'/payment/list/','name':'payment_list'},
{'title':'下載客戶模板','url':'/payment/list/','name':'payment list'},
]
}
}
I