Ticket #8145: 8145.diff

File 8145.diff, 1.3 KB (added by Tim Graham, 15 years ago)
  • docs/topics/auth.txt

     
    212212    .. method:: models.User.has_perm(perm)
    213213
    214214        Returns ``True`` if the user has the specified permission, where perm is
    215         in the format ``"<app label>.<permission codename>"``.
    216         If the user is inactive, this method will always return ``False``.
     215        in the format ``"<app label>.<permission codename>"``. (see
     216        `permissions`_ section below). If the user is inactive, this method will
     217        always return ``False``.
    217218
    218219    .. method:: models.User.has_perms(perm_list)
    219220
     
    10991100    def limited_object_detail(*args, **kwargs):
    11001101        return object_detail(*args, **kwargs)
    11011102
     1103.. _permissions:
     1104
    11021105Permissions
    11031106===========
    11041107
     
    11411144permissions for new models each time you run :djadmin:`manage.py syncdb
    11421145<syncdb>`.
    11431146
     1147Assuming you have an application with
     1148:attr:`~django.db.models.Options.app_label` ``foo`` and a model named ``Bar``,
     1149to test for basic permissions you should use:
     1150
     1151    * add: ``user.has_perm('foo.add_bar')``
     1152    * change: ``user.has_perm('foo.change_bar')``
     1153    * delete: ``user.has_perm('foo.delete_bar')``
     1154
    11441155.. _custom-permissions:
    11451156
    11461157Custom permissions
Back to Top