Opened 9 years ago

Closed 9 years ago

#5516 closed (fixed)

Allow apps to provide their own commands

Reported by: toddobryan Owned by: russellm
Component: Core (Management commands) Version: master
Severity: Keywords: command
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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 toddobryan 9 years ago.

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by toddobryan

comment:1 Changed 9 years ago by toddobryan

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to toddobryan
  • Patch needs improvement unset

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 9 years ago by adrian

I've deleted the erroneous attachment.

comment:3 follow-up: Changed 9 years ago by akaihola

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 9 years ago by russellm

  • Owner changed from toddobryan to russellm
  • Triage Stage changed from Unreviewed to 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 Changed 9 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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