File: remove.rst

package info (click to toggle)
django-guardian 2.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,732 kB
  • sloc: python: 5,987; javascript: 1,396; makefile: 91; sh: 12
file content (26 lines) | stat: -rw-r--r-- 651 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
.. _remove:

Remove object permissions
=========================

Removing object permissions is as easy as assigning them. Just instead of
:func:`guardian.shortcuts.assign_perm` we would use
:func:`guardian.shortcuts.remove_perm` function (it accepts same arguments).

Example
-------

Let's get back to our fellow Joe::

    >>> site = Site.object.get_current()
    >>> joe.has_perm('change_site', site)
    True

Now, simply remove this permission::

    >>> from guardian.shortcuts import remove_perm
    >>> remove_perm('change_site', joe, site)
    >>> joe = User.objects.get(username='joe')
    >>> joe.has_perm('change_site', site)
    False