📜  用户组模板标签 django - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:26.518000             🧑  作者: Mango

代码示例1
from django import template

register = template.Library() 

@register.filter(name='has_group') 
def has_group(user, group_name):
    return user.groups.filter(name=group_name).exists()