File: show_permissions.rst

package info (click to toggle)
python-django-extensions 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 2,820 kB
  • sloc: python: 18,601; javascript: 7,354; makefile: 108; xml: 17
file content (78 lines) | stat: -rw-r--r-- 2,012 bytes parent folder | download
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Show Permissions
================

:synopsis: Show all permissions for Django models

Introduction
------------

The ``show_permissions`` management command lists all permissions for the models in your Django project.
By default, it excludes built-in Django apps such as ``admin``, ``auth``, ``contenttypes``, and ``sessions``.

This command is useful to quickly inspect the permissions assigned to models, especially when customizing permission logic or managing role-based access.

Basic Usage
-----------

.. code-block:: bash

    python manage.py show_permissions

This will output the list of permissions for models in all installed apps **excluding** built-in Django apps.

Examples
--------

Show permissions for specific apps and models:

.. code-block:: bash

    python manage.py show_permissions blog
    python manage.py show_permissions blog.Post

Show permissions including built-in Django apps:

.. code-block:: bash

    python manage.py show_permissions --all

Show permissions for only a specific app using the `--app-label` option:

.. code-block:: bash

    python manage.py show_permissions --app-label blog

Options
-------

* ``--all``
  Include permissions for Django’s built-in apps (``admin``, ``auth``, ``contenttypes``, ``sessions``).

* ``--app-label <label>``
  Only show permissions for the specified app label.

* ``app_label.model`` (positional argument)
  Restrict output to specific model(s), optionally prefixed by app label.

* ``--verbosity {0,1,2,3}``
  Set verbosity level (default: 1).

* ``--settings <path>``
  Set a specific Django settings module.

* ``--pythonpath <path>``
  Add a path to the Python module search path.

* ``--traceback``
  Show full traceback on error.

* ``--no-color`` / ``--force-color``
  Toggle colored output.

* ``--skip-checks``
  Skip Django’s system checks.

Conclusion
----------

The ``show_permissions`` command is a handy tool for developers and administrators to audit or debug permission settings within their Django project.