Skip to main content

Django subcommands in subdirectories

Project description

django-subcommandir

GitHub Actions PyPI PyPI - Python Version framework - Django PyPI - Django Version PyPI - License

Django subcommands in subdirectories

Installation

$ pip install django-subcommandir

Example of usage

my_app
├── ...
├── management
│   ├── commands
│   │   ├── __init__.py
│   │   ├── load
│   │   │   ├── __init__.py
│   │   │   ├── month_report.py
│   │   │   └── year_report.py
│   │   ├── my_app_load.py
│   ├── __init__.py
# .../management/commands/my_app_load.py
from subcommandir import BaseCommand

class Command(BaseCommand):
    subcommand_dir = 'load'
# .../management/commands/load/month_report.py
from django.core.management.base import BaseCommand

class Command(BaseCommand):
    def add_arguments(self, parser):
        parser.add_argument('--start', ...)
        ...

    def handle(self, *args, **options):
        ...

Command calls:

$ python manage.py my_app_load year_report
$ python manage.py my_app_load month_report --start="2021-01" --end="2021-02"

or

from django.core.management import call_command

def load_year_report():
    call_command('my_app_load', 'year_report')
    
def load_month_report():
    call_command('my_app_load', 'month_report', start=...)

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.

Files for django-subcommandir, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django_subcommandir-0.1.1-py3-none-any.whl (6.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-subcommandir-0.1.1.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page