mirror of
https://github.com/django/django.git
synced 2025-08-02 18:13:02 +00:00
Fixed #18991 -- Allowed permission lookup by "if in"
When looking permissions from PermWrapper it is now possible to use {% if "someapp.someperm" in perms %} instead of {% if perms.someapp.someperm %}.
This commit is contained in:
parent
c2532825db
commit
d5a4f209c3
7 changed files with 75 additions and 7 deletions
|
@ -1710,6 +1710,20 @@ Thus, you can check permissions in template ``{% if %}`` statements:
|
|||
<p>You don't have permission to do anything in the foo app.</p>
|
||||
{% endif %}
|
||||
|
||||
.. versionadded:: 1.5
|
||||
Permission lookup by "if in".
|
||||
|
||||
It is possible to also look permissions up by ``{% if in %}`` statements.
|
||||
For example:
|
||||
|
||||
.. code-block:: html+django
|
||||
|
||||
{% if 'foo' in perms %}
|
||||
{% if 'foo.can_vote' in perms %}
|
||||
<p>In lookup works, too.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
Groups
|
||||
======
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue