Skip to main content

Django Commands UI

This project offers a solution to list and execute all existing management commands in your Django project.

Requirements

This project requires Python 3.10 or greater.

Configuration

To install and configure it these steps should be followed:

  1. Install the dependency from PyPi.

    pip install django-commands-ui
    
  2. Add commands_ui as an installed app in your Django project.

  3. If you haven't already done so, you will need to add celery to your django project. You can follow the steps in the First steps with Django guide if you haven't used celery before.

  4. Add the root location of your management commands to your installed apps. For example, if your management commands are in the commands folder in your project root, you would add your-project-name.commands to your installed apps.

  5. Add these required settings:

     # Celery app name.
     COMMANDS_UI_CELERY_APP = ""
    
     # Working celery queue name for delayed jobs.
     COMMANDS_UI_DELAYED_JOBS_QUEUE = ""
    
     # Working celery queue name for standard jobs.
     COMMANDS_UI_JOBS_QUEUE = ""
    
     # Tuple of compiled regexes to extract the runnable commands from.
     # By default, all commands from all installed apps are extracted.
     COMMANDS_UI_JOB_APPS = (re.compile(r".*"),)
    
     # Primary database identifyer, not the replica one.
     DATABASE_PRIMARY = getattr(settings, "DATABASE_PRIMARY", "default")
    
     # Define if the current environment is a cron environment.
     CRON_ENVIRONMENT = getattr(settings, "CRON_ENVIRONMENT", False)
    
  6. Include package URLs to your base urls file like this:

    path("jobs/", include("commands_ui.urls")),
    
  7. Create tables:

    python manage.py migrate commands_ui
    

It is recommended to override base.html so the appearance is customizable, as all django-commands-ui templates extend from it.

Documentation

Implementing a management command job

The only needed thing for implementing a working management command job in django-commands-ui is extending the existing JobBasedCommand. This class adds some default arguments (such as --job-id).

Example on how to use this class:

from typing import Any
from commands_ui import management_commands
from django.core.management.base import CommandParser

# Extend the JobBasedCommand class
class Command(management_commands.JobBasedCommand):
   def handle(self, *args: Any, **options: Any) -> None:
      # Any time `self.print` is used, the message will be added to both standard output and
      # Job output.
      self.print("Starting")
      for i in range(0, 20):
         self.print(i)
      self.print("Finishing")

Command Grouping

You can group types of commands by adding a interface_name class attribute to your management command class. This will group all commands with the same interface_name together in the UI. For example you can group cronjobs together by adding interface_name = "cron" to all your cronjobs.

from typing import Any
from commands_ui import management_commands
from django.core.management.base import CommandParser

# Extend the JobBasedCommand class
class Command(management_commands.JobBasedCommand):
    interface_name = "cron"
   def handle(self, *args: Any, **options: Any) -> None:
      ...

Metadata

Release files for django-commands-ui 0.0.2

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

Source distribution (sdist)

Source distribution for django-commands-ui 0.0.2
File Size Uploaded Provenance
django-commands-ui-0.0.2.tar.gz 22.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-commands-ui 0.0.2
File Interpreter ABI Platform
django_commands_ui-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 50.7 kB

Release files / django-commands-ui-0.0.2.tar.gz

Download URL django-commands-ui-0.0.2.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
82ce95605b4b6c18c555b9c3a2d6ba6d49781ae2f3b98d95b3941f60528c32f1
BLAKE2b-256 checksum
How to use checksums
c5d9f0fab02f4f66471d113ed81deb2049a2d0ce016ddeea94a216b19e40f02a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / django_commands_ui-0.0.2-py3-none-any.whl

Download URL django_commands_ui-0.0.2-py3-none-any.whl
Size 27.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21508fd73890a21f6a3f2a27241b343332b608d4eb07e72bdb986e58eede5763
BLAKE2b-256 checksum
How to use checksums
efc6a759839bf9141282db62bfd2907bb5df52a5ecca29d72f7fef2afbcf4c9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Security for django-commands-ui 0.0.2

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.

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