Skip to content

call_command, get_commands, and find_commands don't work with our custom commands #2

Open
@aaronsgithub

Description

@aaronsgithub

In Django, a command is an argument to the django-admin or manage.py cli's which exposes some functionality.

Commands are defined with classes which subclass django.core.management.base.BaseCommand.

In order to be discoverable by django, the commands must also be defined using the following file-directory pattern 1:

polls/
    __init__.py
    models.py
    management/
        __init__.py
        commands/
            __init__.py
            _private.py
            closepoll.py
    tests.py
    views.py

The core commands distributed with django are defined in this manner at django.core.management.commands.

At present, we have used an alternative approach where we inject our custom commands into our own cli with overwritten fetch_command and main_help_text methods on the LitManagementUtility (which provides the litdjango cli).

This implementation breaks the functions found at:

from django.core.management import get_commands, find_commands, call_command

which are mostly used internally and for testing in django.

We should probably refactor this at some point.

Resources

Footnotes

  1. Django documentation - How to create custom django-admin commands

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions