A Django app to run management commands from the admin panel
Project description
django-admin-commander
A Django app to run management commands from the admin panel with action logging and permission control.
Installation
pip install django-admin-commander
Usage
Add "django_admin_commander" to the end of INSTALLED_APPS in your project's settings.py:
INSTALLED_APPS = [
...,
"django_admin_commander",
]
Run python manage.py migrate to register the dummy command model.
Next, add a setting named ADMIN_COMMANDS to your project's settings.py. This setting should be a dictionary where:
- Keys are strings representing the app names.
- Values are either the string
"__all__"to enable all commands for the app, or an iterable of strings specifying which commands to show.
To enable general Django commands, use the app name "django.core". For example:
ADMIN_COMMANDS = {
"django.contrib.staticfiles": "__all__",
"django.core": ["check", "diffsettings"],
"django.contrib.sessions": "__all__",
}
That's it! Now, when you access the admin panel with the custom permission enabled explicitly or as a superuser, you'll see a section for running management commands. Commands you've executed will also appear in your recent actions panel:
Clicking View or Run Management Commands opens a view where you can choose and execute the enabled commands.
Once selected, the command usage info is automatically displayed below the Run Command button:
You can pass any command arguments in the Arguments field.
If the command expects user input, it can be provided in the User Input field and will be passed to the command when prompted.
[!NOTE] If you don't want to allow input to be passed to the command prompt, you can disable the
User Inputfield entirely by setting ADMIN_COMMANDS_ALLOW_USER_INPUT toFalsein your project'ssettings.py.
After execution, the result is displayed as a message at the top of the screen:
[!CAUTION] Some commands are not suited to be run this way and may cause the response process to hang. For example, the
django.corecommandtest. It's your responsibility to enable only the commands you actually want to run from the admin panel.
Clicking the History button (with the appropriate permission or as a superuser) lets you view all log entries for executed commands:
Permissions
In addition to standard admin view checks, django-admin-commander verifies whether the user has the custom run_management_command permission before allowing access to the run command view or executing commands:
If the user is not a superuser, this permission must be explicitly granted.
To access the History view, the user must be a superuser or have the default Django "admin.view_logentry" permission.
Settings
List of available settings:
ADMIN_COMMANDS
A dictionary where keys are app names and values are either `'__all__'` to show all commands for the app or an iterable of command names to show. Default is an empty dictionary.
ADMIN_COMMANDS_ALLOW_USER_INPUT
Set to `True` to allow user input to be passed to the command's stdin when prompted. Set to `False` to disable the field. Default is `True`.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_admin_commander-0.4.0.tar.gz.
File metadata
- Download URL: django_admin_commander-0.4.0.tar.gz
- Upload date:
- Size: 370.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a72dd03bfa8993efb94bbd553d2d3e88a380850c6cfcb1d65f7ceb6dd2eb2020
|
|
| MD5 |
173ff39369355cdb6992217e58ed38a5
|
|
| BLAKE2b-256 |
0dd65285b9bcfe7ef8ca63f3065392dbd1311a23968b021e830772cfcded450b
|
Provenance
The following attestation bundles were made for django_admin_commander-0.4.0.tar.gz:
Publisher:
python-publish.yml on Lcrs123/django-admin-commander
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_admin_commander-0.4.0.tar.gz -
Subject digest:
a72dd03bfa8993efb94bbd553d2d3e88a380850c6cfcb1d65f7ceb6dd2eb2020 - Sigstore transparency entry: 309752671
- Sigstore integration time:
-
Permalink:
Lcrs123/django-admin-commander@e3cc79086fa5a9fa129bde3c68fa28ccd884b9ca -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/Lcrs123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e3cc79086fa5a9fa129bde3c68fa28ccd884b9ca -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_admin_commander-0.4.0-py3-none-any.whl.
File metadata
- Download URL: django_admin_commander-0.4.0-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b634aca9cb4ff79e2d048365eab45517416754000ec40ee857aa79282c154c4
|
|
| MD5 |
93a6affb6b0f1914201867b22aae0ee8
|
|
| BLAKE2b-256 |
f5d8cf7b09f058ee0cf9da9646253ec7e6e5d1d505d69ec3966e5a717e89da5f
|
Provenance
The following attestation bundles were made for django_admin_commander-0.4.0-py3-none-any.whl:
Publisher:
python-publish.yml on Lcrs123/django-admin-commander
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_admin_commander-0.4.0-py3-none-any.whl -
Subject digest:
4b634aca9cb4ff79e2d048365eab45517416754000ec40ee857aa79282c154c4 - Sigstore transparency entry: 309752683
- Sigstore integration time:
-
Permalink:
Lcrs123/django-admin-commander@e3cc79086fa5a9fa129bde3c68fa28ccd884b9ca -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/Lcrs123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e3cc79086fa5a9fa129bde3c68fa28ccd884b9ca -
Trigger Event:
release
-
Statement type: