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
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 our dummy command model.
Now add a setting named ADMIN_COMMANDS to your project settings.py. The setting should be a dict with keys as strings with the app names you want to enable commands for and the mapped values should be either the string literal '__all__' to show all commands for the app or an iterable of strings with the command names 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 our custom permission enabled explicitely or as a superuser, you'll see a section for running management commands. Commands you have tried to run will also be shown on your recent actions panel:
When you click View or Run Management Commands, you'll open a view where you can choose and execute the enabled commands.
Once chosen, the command usage info is automatically shown below the Run Command button:
Any command args can be passed in the Arguments field. If the command expects any user input, it can be passed in the User Input field and will be passed to the command when prompted to.
Once run, the result of the execution is shown as a message on top of the screen:
If you click the History button and have the django admin view log entry permission enabled explicitely or as a superuser, you'll be able to see all log entries for executed commands:
Permissions
Aside from the regular admin view checks, django-admin-commander checks if the user has the custom run_management_command permission before allowing opening the run command view or running commands:
If the user is not a superuser, it must be specifically added to allow running commands and accessing the view.
For accesing the History view, the user must be a superuser or have the default django "admin.view_logentry" permission.
Warning
Some commands are not suited to be run like this and may cause the response process or the server itself to hang, for example, the django.core command test. It's your responsibility to enable only the commands you actually want to be able to run from the admin panel.
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.2.0.tar.gz.
File metadata
- Download URL: django_admin_commander-0.2.0.tar.gz
- Upload date:
- Size: 381.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5216843f138e612a41697afb3800b969c855b5d09c0577246b2abf5d24c624e1
|
|
| MD5 |
d810da39af2ace72c8590e138f011faf
|
|
| BLAKE2b-256 |
34b548f88ff81db593b2ad5a00b5f0a482643584b9bd523257cc40dcb7015b69
|
Provenance
The following attestation bundles were made for django_admin_commander-0.2.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.2.0.tar.gz -
Subject digest:
5216843f138e612a41697afb3800b969c855b5d09c0577246b2abf5d24c624e1 - Sigstore transparency entry: 302685643
- Sigstore integration time:
-
Permalink:
Lcrs123/django-admin-commander@031af0b881eb19f1acf377859e449d024ca694dc -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Lcrs123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@031af0b881eb19f1acf377859e449d024ca694dc -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_admin_commander-0.2.0-py3-none-any.whl.
File metadata
- Download URL: django_admin_commander-0.2.0-py3-none-any.whl
- Upload date:
- Size: 27.8 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 |
c6fe59226eb06b600c01409d00cae5d734929461b4f96d68b2796e8b66e79e17
|
|
| MD5 |
8b6373d3e86e25e5d0b67f53e991bc69
|
|
| BLAKE2b-256 |
5120a130e47eda253172efcc6b04e2b4cfab4c214b78eaca029a453c16f6415d
|
Provenance
The following attestation bundles were made for django_admin_commander-0.2.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.2.0-py3-none-any.whl -
Subject digest:
c6fe59226eb06b600c01409d00cae5d734929461b4f96d68b2796e8b66e79e17 - Sigstore transparency entry: 302685654
- Sigstore integration time:
-
Permalink:
Lcrs123/django-admin-commander@031af0b881eb19f1acf377859e449d024ca694dc -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Lcrs123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@031af0b881eb19f1acf377859e449d024ca694dc -
Trigger Event:
release
-
Statement type: