permission.templatetags package

Submodules

permission.templatetags.patch module

django if templatetag patch

permission.templatetags.patch.parser_patch(instance)[source]

permission.templatetags.permissionif module

permissionif templatetag

class permission.templatetags.permissionif.PermissionIfParser(tokens)[source]

Bases: django.template.smartif.IfParser

Permission if parser

Methods

OPERATORS = {'and': <class 'django.template.smartif.Operator'>, '>=': <class 'django.template.smartif.Operator'>, 'not in': <class 'django.template.smartif.Operator'>, '==': <class 'django.template.smartif.Operator'>, 'of': <class 'django.template.smartif.Operator'>, '<=': <class 'django.template.smartif.Operator'>, '<': <class 'django.template.smartif.Operator'>, '=': <class 'django.template.smartif.Operator'>, 'in': <class 'django.template.smartif.Operator'>, 'not': <class 'django.template.smartif.Operator'>, 'has': <class 'django.template.smartif.Operator'>, '!=': <class 'django.template.smartif.Operator'>, 'or': <class 'django.template.smartif.Operator'>, '>': <class 'django.template.smartif.Operator'>}

use extra operator

translate_token(token)[source]
class permission.templatetags.permissionif.TemplatePermissionIfParser(parser, *args, **kwargs)[source]

Bases: permission.templatetags.permissionif.PermissionIfParser

Methods

create_var(value)[source]
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

permission.templatetags.permissionif.of_operator(context, x, y)[source]

‘of’ operator of permission if

This operator is used to specify the target object of permission

Module contents