Skip to main content

Reusable Django app for executing management commands from Django Admin

Project description

django-management-ui

Run any Django management command from the admin panel. No models, no migrations — just install and go.

Documentation

The app introspects argparse definitions of your commands and dynamically builds forms with appropriate widgets: text inputs, checkboxes, dropdowns, number fields, file uploads for Path arguments.

Features

  • Automatic discovery of all registered management commands
  • Dynamic form generation from argparse argument types
  • File upload with temp file lifecycle for Path arguments (upload or enter path as text)
  • Grouped display: command-specific args + collapsible BaseCommand options
  • Output capture (stdout/stderr) with execution time
  • Superuser-only access
  • Appears on the Django Admin index page in the app list as "Commands" section
  • Command blacklist to hide dangerous commands
  • Configurable execution timeout (default 30s)
  • Output truncation for large command outputs

Quick start

1. Install

pip install django-management-ui

2. Add to INSTALLED_APPS

INSTALLED_APPS = [
    ...
    "management_ui",
]

3. Add URL configuration

# urls.py
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path("admin/", include("management_ui.urls")),
    path("admin/", admin.site.urls),
]

That's it. Navigate to /admin/commands/ to see all available commands.

How it works

argparse introspection → ArgumentInfo → Django form field → execute command → CommandResult
  1. Discovery — finds all registered management commands via django.core.management.get_commands()
  2. Introspection — parses argparse _actions into ArgumentInfo dataclasses
  3. Form generation — maps argument types to Django form fields:
Argument type Form field
store_true / store_false BooleanField (checkbox)
choices ChoiceField (dropdown)
type=int IntegerField
type=float FloatField
type=Path PathField (file upload + text input toggle)
default / type=str CharField
  1. Execution — runs command via call_command(), captures stdout/stderr, measures duration
  2. Result — displays output with success/error styling

Path argument support

When a command argument has type=Path, the form renders a dual-mode widget:

  • File upload mode (default) — upload a file, it's saved to /tmp/ with a unique name, path passed to command, temp file cleaned up after execution
  • Text path mode — enter a server path as text (toggle via "or enter path as text" link)

Requirements

  • Python >= 3.11
  • Django >= 4.2

License

MIT

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_management_ui-0.4.0.tar.gz (544.9 kB view details)

Uploaded Source

Built Distribution

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

django_management_ui-0.4.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file django_management_ui-0.4.0.tar.gz.

File metadata

  • Download URL: django_management_ui-0.4.0.tar.gz
  • Upload date:
  • Size: 544.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_management_ui-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b66d48390f56c72d2a6e10dd48eba2cd5d1f18192f475de56eb27d22d1a67f0d
MD5 c37f930cdf0afe662e3e1c5fc39bfe8f
BLAKE2b-256 1096c92f46357aee555f7b28af619a1f30751a7ee2df1a1746036dbed6bfb63d

See more details on using hashes here.

File details

Details for the file django_management_ui-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: django_management_ui-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_management_ui-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18e714eb5b22e5b576d524e816f2f597c0839222faacdfa8593d20e42d4fdca5
MD5 3f4c936af27fe82ae2b44984e8f65552
BLAKE2b-256 ef68fedd38f3a306e0cbb249cec57e7c4833435c748bf9167a56a659b0cd6093

See more details on using hashes here.

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