diff options
| author | Jannis Leidel <jannis@leidel.info> | 2009-12-18 10:07:34 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2009-12-18 10:07:34 +0000 |
| commit | a2ef46316c492cc2c4b2e28bbbf73db3ebc29e1e (patch) | |
| tree | ede6db3cf019e492a9139decee9c157cc799158f /docs/topics/auth.txt | |
| parent | ebb8ca1cd7c2833309c3febfb03ad9abbb074d37 (diff) | |
Fixed #8145 - Documented the codenames of the default auth permissions
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11909 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics/auth.txt')
| -rw-r--r-- | docs/topics/auth.txt | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt index c85ff604bf..8aae4f5e73 100644 --- a/docs/topics/auth.txt +++ b/docs/topics/auth.txt @@ -225,8 +225,9 @@ Methods .. method:: models.User.has_perm(perm, obj=None) Returns ``True`` if the user has the specified permission, where perm is - in the format ``"<app label>.<permission codename>"``. - If the user is inactive, this method will always return ``False``. + in the format ``"<app label>.<permission codename>"``. (see + `permissions`_ section below). If the user is inactive, this method will + always return ``False``. .. versionadded:: 1.2 @@ -1122,6 +1123,8 @@ generic view itself. For example:: def limited_object_detail(*args, **kwargs): return object_detail(*args, **kwargs) +.. _permissions: + Permissions =========== @@ -1164,6 +1167,14 @@ models being installed at that time. Afterward, it will create default permissions for new models each time you run :djadmin:`manage.py syncdb <syncdb>`. +Assuming you have an application with an +:attr:`~django.db.models.Options.app_label` ``foo`` and a model named ``Bar``, +to test for basic permissions you should use: + + * add: ``user.has_perm('foo.add_bar')`` + * change: ``user.has_perm('foo.change_bar')`` + * delete: ``user.has_perm('foo.delete_bar')`` + .. _custom-permissions: Custom permissions |
