mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +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:
@@ -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
|
||||
======
|
||||
|
||||
|
||||
Reference in New Issue
Block a user