Skip to main content

djangocommand

Python client for DjangoCommand - run, schedule, and audit Django management commands without SSH access.

Installation

pip install djangocommand-runner

Quick Start

  1. Add to your INSTALLED_APPS:
INSTALLED_APPS = [
    # ...
    'djangocommand',
]
  1. Add your API key to settings.py:
DJANGOCOMMAND_API_KEY = "dc_your_api_key_here"
  1. Start the runner:
python manage.py djangocommand start

The runner will connect to DjangoCommand, sync your available commands, and start polling for executions.

Configuration

API key

Your project's API key (get this from the DjangoCommand dashboard)

DJANGOCOMMAND_API_KEY = "dc_..."

Enabled (allowed) commands

Enable additional commands:

import djangocommand
DJANGOCOMMAND_ALLOWED_COMMANDS = tuple(
    *djangocommand.DEFAULT_ALLOWED_COMMANDS,
    "my_custom_command",
    "another_command",
)

Or explicitly allow only specific commands (skip the default ones):

DJANGOCOMMAND_ALLOWED_COMMANDS = (
    "my_custom_command",
    "another_command",
)

Order does not matter.

By default, only commands in DEFAULT_ALLOWED_COMMANDS can be executed remotely:

Default value:

DEFAULT_ALLOWED_COMMANDS = (
    # Database
    "migrate", "showmigrations", "dbbackup", "createcachetable",
    # Static files
    "collectstatic", "findstatic",
    # Maintenance
    "clearsessions", "check", "sendtestemail", "diffsettings",
    # Data
    "dumpdata", "inspectdb",
    # Testing
    "test",
    # django-extensions
    "show_urls", "validate_templates", "clear_cache",
    # Wagtail
    "fixtree", "publish_scheduled", "update_index",
)

DISCLAIMER: This list is not fully vetted. You are encouraged to only allow commands that you trust and have vetted yourself.

Alternative - Blocklist Mode

Alternative to the "ALLOWED" list is the "DISALLOWED" list.

In this mode all commands are allowed except for the ones in the blocklist.

This mode is inherently less secure because newly added commands are automatically allowed.

CAUTION: Any new commands will by allowed by default in this mode!

DJANGOCOMMAND_USE_BLOCKLIST = True

Default value:

DEFAULT_DISALLOWED_COMMANDS = (
    # Database destruction
    "flush", "sqlflush", "reset_db", "dbrestore", "loaddata",
    # Interactive shells
    "shell", "shell_plus", "dbshell",
    # Development servers
    "runserver", "runserver_plus", "testserver",
    # Security sensitive
    "createsuperuser", "changepassword",
    # File modifications
    "makemigrations", "squashmigrations",
)

DISCLAIMER: This list is not exhaustive. You are responsible for ensuring that only safe commands are allowed.

Optional / Advanced Settings

# Server URL (default: https://app.djangocommand.com)
DJANGOCOMMAND_SERVER_URL = "https://app.djangocommand.com"

# Runner heartbeat interval in seconds (default: 30, minimum: 5)
DJANGOCOMMAND_HEARTBEAT_INTERVAL = 30

# HTTP request timeout in seconds (default: 30)
DJANGOCOMMAND_REQUEST_TIMEOUT = 30

# Max retries for failed requests (default: 3)
DJANGOCOMMAND_MAX_RETRIES = 3

# Hosts allowed to use HTTP instead of HTTPS (default: localhost only)
DJANGOCOMMAND_ALLOW_HTTP_HOSTS = ['localhost', '127.0.0.1', '::1']

Metadata-Only Mode

For commands that produce sensitive output (credentials, PII) or very high-volume output, you can enable metadata-only mode. In this mode, the command executes normally but stdout/stderr are not captured or stored.

# Commands that always run in metadata-only mode
DJANGOCOMMAND_METADATAONLY_COMMANDS = (
    "generate_api_keys",
    "export_user_data",
    "sync_large_dataset",
)

Additionally, the dashboard can also enable metadata-only mode on a per-command basis via the command configuration settings. Either the client setting or the dashboard setting will trigger metadata-only mode.

In metadata-only mode:

  • The command executes normally
  • Exit code and duration are still tracked
  • Output shows: "(metadata-only mode, no output captured)"

Running the Runner

Current architecture supports only 1 runner per project.

Foreground

python manage.py djangocommand start

Starts the runner in the foreground. Press Ctrl+C to stop.

This is the recommended option for Kubernetes, systemd, Docker, and similar process managers that handle lifecycle and restarts.

Background (detached)

python manage.py djangocommand start -d

Starts the runner in the background.

This is recommended for development and testing only. It can be used in production where other process managers are not available. YMMV.

Managing the Runner

Use these commands to manage a runner.

Works whether the runner is running in the foreground or background.

# Check if the runner is running
python manage.py djangocommand status

# Stop the background runner
python manage.py djangocommand stop [--force]

# Restart the runner
python manage.py djangocommand restart [-d]

License

MIT

Metadata

Release files for djangocommand-runner 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangocommand-runner 0.1.0
File Size Uploaded Provenance Actions
djangocommand_runner-0.1.0.tar.gz 26.4 kB Without provenance Details for djangocommand_runner-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for djangocommand-runner 0.1.0
File Interpreter ABI Platform Actions
djangocommand_runner-0.1.0-py3-none-any.whl Python 3 none any Details for djangocommand_runner-0.1.0-py3-none-any.whl

Total release size: 57.9 kB

Release files / djangocommand_runner-0.1.0.tar.gz

Download URL djangocommand_runner-0.1.0.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
af4a54cecec7f4cea7796d8a7a3c929dcc4031908e5b66568522dad8ff4c21d9
BLAKE2b-256 checksum
How to use checksums
a717b25011a3bc8cf789ac5376d9223cccb07c8b7e1961351586b9fc1705e8cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / djangocommand_runner-0.1.0-py3-none-any.whl

Download URL djangocommand_runner-0.1.0-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e22750d9052ca50eb1ac0ac5bc98da2e44368b54493a94de81e03ab435a39c6c
BLAKE2b-256 checksum
How to use checksums
e31a81fe43aa24e7cba06055626f7a5246db6ea5ea8db1f09d2e5545a49f1d3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for djangocommand-runner 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page