Skip to main content

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:

admin panel view

When you click View or Run Management Commands, you'll open a view where you can choose and execute the enabled commands.

run command view command groups

Once chosen, the command usage info is automatically shown below the Run Command button:

usage info

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:

command output

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:

history

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:

permission

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

django_admin_commander-0.2.0.tar.gz (381.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_admin_commander-0.2.0-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

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

Hashes for django_admin_commander-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5216843f138e612a41697afb3800b969c855b5d09c0577246b2abf5d24c624e1
MD5 d810da39af2ace72c8590e138f011faf
BLAKE2b-256 34b548f88ff81db593b2ad5a00b5f0a482643584b9bd523257cc40dcb7015b69

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_admin_commander-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_commander-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6fe59226eb06b600c01409d00cae5d734929461b4f96d68b2796e8b66e79e17
MD5 8b6373d3e86e25e5d0b67f53e991bc69
BLAKE2b-256 5120a130e47eda253172efcc6b04e2b4cfab4c214b78eaca029a453c16f6415d

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page