Opened 17 years ago
Closed 17 years ago
#5516 closed (fixed)
Allow apps to provide their own commands
Reported by: | Todd O'Bryan | Owned by: | Russell Keith-Magee |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Keywords: | command | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This patch allows users to create arbitrary commands in each app that can be invoked by django-admin.py
.
Inside an app, users create a management.commands.my_command
module for each command they'd like to add that must include a subclass of
django.core.management.base.BaseCommand
called
Command
. A command is invoked with
app_name.my_command
, where
app_name
is the path to the app provided in the
INSTALLED_APPS
setting.
Commands installed in this way are automatically plugged into the help system provided that the user has provided the Django settings correctly, either by using manage.py
, setting the
DJANGO_SETTINGS_MODULE
environment variable, or by using the
--settings
option to
django-admin.py
.
Attachments (1)
Change History (6)
by , 17 years ago
Attachment: | user_commands.patch added |
---|
comment:1 by , 17 years ago
Owner: | changed from | to
---|
follow-up: 4 comment:3 by , 17 years ago
I like it. Great idea. So far I've written separate scripts to do various maintenance, verification or import tasks for the database. Each of those scripts has to repeat the same dance for setting up the environment, which manage.py would provide for free. I'll use this immediately if it makes it into Django.
comment:4 by , 17 years ago
Owner: | changed from | to
---|---|
Triage Stage: | Unreviewed → Accepted |
Replying to akaihola:
I like it. Great idea.
Short version - this feature is coming, hopefully soon.
Long version - this idea has been approved for inclusion by the BFDLs, so it's just a matter of getting an implementation that works. I've made two attempts in the past, which both failed because of some nasty edge cases. I've had a quick look at this patch, and it looks promising. I'm hoping to have a look at it tonight.
comment:5 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I accidentally uploaded the wrong patch.
user_commands
is correct. The other one can be deleted (and I would delete it if I knew how).