Skip to main content

A powerful suite of management commands for Django projects with integrated logging support

Project description

Django Commands Suite (DCS)

Django Commands Suite is a Django app that provides a powerful suite of management commands for your projects.
It helps automate repetitive tasks such as:

  • Database backup
  • Creating superusers quickly
  • Seeding fake data
  • Cache management
  • Logging command executions
  • Running custom commands via Web Terminal

Installation

Install via pip:

pip install django-commands-suite

Add it to INSTALLED_APPS in your Django settings:

INSTALLED_APPS = [
    ...
    'django_commands_suite',
]

Run migrations to create necessary tables:

python manage.py makemigrations django_commands_suite
python manage.py migrate

Usage

1. Django Commands

View all DCS commands:

python manage.py dcs_help

Create a superuser quickly:

python manage.py quick_superuser

Backup your database:

python manage.py backup_db

Seed fake data for a model:

python manage.py dummy_data --model myapp.MyModel --count 10

2. Web Terminal

DCS provides a Web Terminal to run commands from the browser:

  • URL: /dcs/terminal/
  • Supports custom DCS commands
  • Example commands :
quick_superuser # Creates a superuser

Logging

All commands run via DCS (CLI or Web Terminal) are logged automatically using CommandLog.
This allows you to keep track of:

  • Who ran a command
  • When it was run
  • Output and status (success or error)

Example usage of logging in a custom command:

from django_commands_suite.utils import log_command

log_command("my_command", {"option": "value"}, "success", "Command output here")

Custom DCS Commands

You can define your own commands prefixed with dcs_ for Web Terminal usage.
Example:

from django.core.management.base import BaseCommand
from django_commands_suite.utils import log_command

class Command(BaseCommand):
    help = "Say hello"

    def handle(self, *args, **kwargs):
        msg = "Hello from DCS!"
        self.stdout.write(msg)
        log_command("dcs_hello", {}, "success", msg)

Utility Function: run_command

run_command allows you to run any Django management command from code and automatically logs its output and status in CommandLog.

Signature

run_command(command_name: str, *args, **kwargs)

Parameters

  • command_name (str): Django command name ("quick_superuser", etc.)
  • *args: Positional arguments for the command
  • **kwargs: Keyword arguments/options for the command

Example Usage

from django_commands_suite.utils import run_command

# Run quick_superuser
output = run_command("quick_superuser")
print(output)

This function is great for automation scripts, seeders, or custom management tasks in Django projects.


Contributing

Contributions are welcome!
Feel free to:

  • Open issues
  • Submit pull requests
  • Suggest new commands

License

MIT License

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_commands_suite-0.2.5.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

django_commands_suite-0.2.5-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file django_commands_suite-0.2.5.tar.gz.

File metadata

  • Download URL: django_commands_suite-0.2.5.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for django_commands_suite-0.2.5.tar.gz
Algorithm Hash digest
SHA256 88b8469bbba665bf04a9ee328f2d25115df05688149832d4a8f8c6866576280b
MD5 d5bace3fee1a3d0d534127e8a1481cd0
BLAKE2b-256 cf3cbfd3181bac3feb183bbe102f9d9f2a6d2606a798ee31ebe945b7c4904979

See more details on using hashes here.

File details

Details for the file django_commands_suite-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_commands_suite-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 337568830e434b4f3983236e8fc74a841c96df89ba76fe0b1ae4310cb4255fa4
MD5 c88fb6fe1df6e7983fc0f5fe1550dbb8
BLAKE2b-256 d5cc7a5076b9e7cb7555b712b09316d3e2cd163692ba653fd28dc14772741c7a

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