oioioi.base.templatetags.check_perm
¶
Module Contents¶
Classes¶
Functions¶
|
A template tag to look up object permissions. |
Attributes¶
- class oioioi.base.templatetags.check_perm.CheckPermNode(perm, obj, var)[source]¶
Bases:
django.template.Node
- oioioi.base.templatetags.check_perm.check_perm(parser, token)[source]¶
A template tag to look up object permissions.
The current user is tested agains the given permission on the given object. Current user is taken from the template context, so the
django.contrib.auth.context_processors.auth
template context processor must be present insettings.TEMPLATE_CONTEXT_PROCESSORS
.Usage:
{% load check_perm %} {% check_perm "some_permission" for some_object as variable %} {% if variable %} <p>This is shown if the user has some_permission on some_object.</p> {% endif %}