permission.templatetags package
Submodules
permission.templatetags.permissionif module
permissionif templatetag
- class permission.templatetags.permissionif.PermissionIfParser(tokens)[source]
Bases:
IfParser
Permission if parser
- OPERATORS = {'!=': <class 'django.template.smartif.infix.<locals>.Operator'>, '<': <class 'django.template.smartif.infix.<locals>.Operator'>, '<=': <class 'django.template.smartif.infix.<locals>.Operator'>, '==': <class 'django.template.smartif.infix.<locals>.Operator'>, '>': <class 'django.template.smartif.infix.<locals>.Operator'>, '>=': <class 'django.template.smartif.infix.<locals>.Operator'>, 'and': <class 'django.template.smartif.infix.<locals>.Operator'>, 'has': <class 'django.template.smartif.infix.<locals>.Operator'>, 'in': <class 'django.template.smartif.infix.<locals>.Operator'>, 'is': <class 'django.template.smartif.infix.<locals>.Operator'>, 'is not': <class 'django.template.smartif.infix.<locals>.Operator'>, 'not': <class 'django.template.smartif.prefix.<locals>.Operator'>, 'not in': <class 'django.template.smartif.infix.<locals>.Operator'>, 'of': <class 'django.template.smartif.infix.<locals>.Operator'>, 'or': <class 'django.template.smartif.infix.<locals>.Operator'>}
use extra operator
- class permission.templatetags.permissionif.TemplatePermissionIfParser(parser, *args, **kwargs)[source]
Bases:
PermissionIfParser
- error_class
alias of
TemplateSyntaxError
- permission.templatetags.permissionif.do_permissionif(parser, token)[source]
Permission if templatetag
Examples
{% if user has 'blogs.add_article' %} <p>This user have 'blogs.add_article' permission</p> {% elif user has 'blog.change_article' of object %} <p>This user have 'blogs.change_article' permission of {{object}}</p> {% endif %} {# If you set 'PERMISSION_REPLACE_BUILTIN_IF = False' in settings #} {% permission user has 'blogs.add_article' %} <p>This user have 'blogs.add_article' permission</p> {% elpermission user has 'blog.change_article' of object %} <p>This user have 'blogs.change_article' permission of {{object}}</p> {% endpermission %}
- permission.templatetags.permissionif.has_operator(context, x, y)[source]
‘has’ operator of permission if
This operator is used to specify the user object of permission