summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorBotond Beres <botondus@gmail.com>2017-10-27 18:02:26 +0100
committerTim Graham <timograham@gmail.com>2017-10-28 12:41:01 -0400
commit41009788a0a73d7a33e102efc5d10208f5174964 (patch)
tree238cb689c54b5c92700b46451297f616e9fb539d /docs
parent6e2ace8c4e186c59f269db4c045dcc5c16191eac (diff)
[2.0.x] Fixed #28131 -- Corrected examples of using attribute lookups on the "perms" template variable.
Backport of 51d7feff872e74d5a53479f62163d5e0024b00ed from master
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/auth/default.txt21
1 files changed, 10 insertions, 11 deletions
diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt
index affabea089..049df901ee 100644
--- a/docs/topics/auth/default.txt
+++ b/docs/topics/auth/default.txt
@@ -1655,21 +1655,20 @@ The currently logged-in user's permissions are stored in the template variable
``django.contrib.auth.context_processors.PermWrapper``, which is a
template-friendly proxy of permissions.
-In the ``{{ perms }}`` object, single-attribute lookup is a proxy to
-:meth:`User.has_module_perms <django.contrib.auth.models.User.has_module_perms>`.
-This example would display ``True`` if the logged-in user had any permissions
-in the ``foo`` app::
+Evaluating a single-attribute lookup of ``{{ perms }}`` as a boolean is a proxy
+to :meth:`User.has_module_perms()
+<django.contrib.auth.models.User.has_module_perms>`. For example, to check if
+the logged-in user has any permissions in the ``foo`` app::
- {{ perms.foo }}
+ {% if perms.foo %}
-Two-level-attribute lookup is a proxy to
-:meth:`User.has_perm <django.contrib.auth.models.User.has_perm>`. This example
-would display ``True`` if the logged-in user had the permission
-``foo.can_vote``::
+Evaluating a two-level-attribute lookup as a boolean is a proxy to
+:meth:`User.has_perm() <django.contrib.auth.models.User.has_perm>`. For example,
+to check if the logged-in user has the permission ``foo.can_vote``::
- {{ perms.foo.can_vote }}
+ {% if perms.foo.can_vote %}
-Thus, you can check permissions in template ``{% if %}`` statements:
+Here's a more complete example of checking permissions in a template:
.. code-block:: html+django