如何检查用户对Django中URL的权限
我有URL-管理员/用户/用户个人资料
我想检查登录用户是否有权访问该操作吗?
def get_nav_list(context, **kwargs):
request = context['request']
navigation = Navigation.objects.all()
menus = []
menu_tree = {}
for nav in navigation:
if nav.parent_id is None:
menus.append(nav.navigation_weight)
menu_tree[nav.id] = {}
menu_tree[nav.id]['parent'] = nav
menu_tree[nav.id]['children'] = {}
for nav in navigation:
if nav.parent_id:
if check_menu_permissions(nav.navigation_link , request.user):
menu_tree[nav.parent_id]['children'][nav.id] = nav
关于check_menu_permissions
函数的问题
Note: I have build navigation Module like wordpress in django