Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aaronsgithub opened this issue Jul 7, 2023 · 0 comments

Comments

@aaronsgithub
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant