Opened 14 years ago

Closed 14 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


This patch allows users to create arbitrary commands in each app that can be invoked by

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 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, setting the DJANGO_SETTINGS_MODULE environment variable, or by using the --settings option to

Attachments (1)

user_commands.patch (8.1 KB) - added by Todd O'Bryan 14 years ago.

Download all attachments as: .zip

Change History (6)

Changed 14 years ago by Todd O'Bryan

Attachment: user_commands.patch added

comment:1 Changed 14 years ago by Todd O'Bryan

Owner: changed from nobody to Todd O'Bryan

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).

comment:2 Changed 14 years ago by Adrian Holovaty

I've deleted the erroneous attachment.

comment:3 Changed 14 years ago by Antti Kaihola

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 would provide for free. I'll use this immediately if it makes it into Django.

comment:4 in reply to:  3 Changed 14 years ago by Russell Keith-Magee

Owner: changed from Todd O'Bryan to Russell Keith-Magee
Triage Stage: UnreviewedAccepted

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 Changed 14 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [6400]) Fixed #5516 -- Added the ability for applications to define their own management commands. Pieces of this patch taken from a contribution by Todd O'Bryan. Thanks Todd.

Note: See TracTickets for help on using tickets.
Back to Top