Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
51d7feff
Kaydet (Commit)
51d7feff
authored
Eki 27, 2017
tarafından
Botond Beres
Kaydeden (comit)
Tim Graham
Eki 28, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28131 -- Corrected examples of using attribute lookups on the "perms" template variable.
üst
73241132
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
default.txt
docs/topics/auth/default.txt
+10
-11
No files found.
docs/topics/auth/default.txt
Dosyayı görüntüle @
51d7feff
...
@@ -1537,21 +1537,20 @@ The currently logged-in user's permissions are stored in the template variable
...
@@ -1537,21 +1537,20 @@ The currently logged-in user's permissions are stored in the template variable
``django.contrib.auth.context_processors.PermWrapper``, which is a
``django.contrib.auth.context_processors.PermWrapper``, which is a
template-friendly proxy of permissions.
template-friendly proxy of permissions.
In the ``{{ perms }}`` object, single-attribute lookup is a proxy to
Evaluating a single-attribute lookup of ``{{ perms }}`` as a boolean is a proxy
:meth:`User.has_module_perms <django.contrib.auth.models.User.has_module_perms>`.
to :meth:`User.has_module_perms()
This example would display ``True`` if the logged-in user had any permissions
<django.contrib.auth.models.User.has_module_perms>`. For example, to check if
in the ``foo`` app::
the logged-in user has any permissions
in the ``foo`` app::
{
{ perms.foo }
}
{
% if perms.foo %
}
Two-level-attribute lookup is a proxy to
Evaluating a two-level-attribute lookup as a boolean is a proxy to
:meth:`User.has_perm <django.contrib.auth.models.User.has_perm>`. This example
:meth:`User.has_perm() <django.contrib.auth.models.User.has_perm>`. For example,
would display ``True`` if the logged-in user had the permission
to check if the logged-in user has the permission ``foo.can_vote``::
``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
.. code-block:: html+django
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment