Fixed #9414 -- Clarified the documentation on the permission decorators. Thanks to timo for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11547 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2009-09-13 01:13:40 +00:00
parent d0c6e9cf63
commit 0e07f80cf4
1 changed files with 7 additions and 6 deletions

View File

@ -212,14 +212,15 @@ Methods
.. method:: models.User.has_perm(perm) .. method:: models.User.has_perm(perm)
Returns ``True`` if the user has the specified permission, where perm is Returns ``True`` if the user has the specified permission, where perm is
in the format ``"<application name>.<lowercased model name>"``. If the in the format ``"<app label>.<permission codename>"``.
user is inactive, this method will always return ``False``. If the user is inactive, this method will always return ``False``.
.. method:: models.User.has_perms(perm_list) .. method:: models.User.has_perms(perm_list)
Returns ``True`` if the user has each of the specified permissions, Returns ``True`` if the user has each of the specified permissions,
where each perm is in the format ``"package.codename"``. If the user is where each perm is in the format
inactive, this method will always return ``False``. ``"<app label>.<permission codename>"``. If the user is inactive,
this method will always return ``False``.
.. method:: models.User.has_module_perms(package_name) .. method:: models.User.has_module_perms(package_name)
@ -1062,8 +1063,8 @@ The permission_required decorator
my_view = permission_required('polls.can_vote')(my_view) my_view = permission_required('polls.can_vote')(my_view)
As for the :meth:`User.has_perm` method, permission names take the form As for the :meth:`User.has_perm` method, permission names take the form
``"<application name>.<lowercased model name>"`` (i.e. ``polls.choice`` for ``"<app label>.<permission codename>"`` (i.e. ``polls.can_vote`` for a
a ``Choice`` model in the ``polls`` application). permission on a model in the ``polls`` application).
Note that :func:`~django.contrib.auth.decorators.permission_required()` Note that :func:`~django.contrib.auth.decorators.permission_required()`
also takes an optional ``login_url`` parameter. Example:: also takes an optional ``login_url`` parameter. Example::