You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Managment commands are assumed to be unique across all apps in a Django project. This can lead to long or obscure command names in attempt to namespace those commands.
Subcommander acts as a proxy command giving the _real_ commands a namespace. The subcommander module can be named after the app name or some derivation. The structure looks as follows:
```bash
myapp/
management/
commands/
myapp.py
subcommands/
cmd1.py
cmd2.py
...
```
The command defined in each module under `subcommands/` are defined [as normal](https://docs.djangoproject.com/en/1.5/howto/custom-management-commands/). The `commands/myapp.py` should look like the following:
```python
from subcommander import Subcommander
classCommand(Subcommander):
subcommands = {
'cmd1': 'cmd1',
'cmd2': 'cmd2',
}
```
The `subcommands` dict looks unnecessary, but it enables mapping a cleaner command line name to the command module, e.g. `load` => `load_data`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters