The Django management commands documentation shows all commands being created in an app/management/commands folder. Is it possible to put commands into subfolders, like app/management/commands/install and app/management/commands/maintenance? How would this be done?
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- Django/Heroku: FATAL: too many connections for rol
- Django is sooo slow? errno 32 broken pipe? dcramer
- Django: Replacement for the default ManyToMany Wid
- Upgrading transaction.commit_manually() to Django
- UnicodeEncodeError when saving ImageField containi
Unfortunatly, as of Django 1.4 there seems to be no way of doing that. The sources for
django.core.management.__init__.py
have this method:As you can see, it only considers files directly inside the
commands
folder, ignoring any subfolders. However, if you "monkey patch" this function somehow, the rest of the code should work fine, since the code that actually creates theCommand
instance is this:So, if you had a command named
subfolder.command
it would load the right script and instantiate the right class.From a practical standpoint, however, I see no use of doing that. Sure, having "namespace'd" commands would be nice, but you can always prefix all your commands with some name if you want, using something else as a separator (such as
_
). The command name length - and the number of keystrokes needed to type them in the terminal - will be the same...