Opened 9 years ago

Closed 4 years ago

#11590 closed New feature (wontfix)

REQUEST: Give LabelCommand an option for default behavior (when no labels are specified)

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


The LabelCommand class is handy, but I've found circumstances where I need a default behavior when no labels are specified on the command line. For example, when specifying directories os.getcwd() provides a reasonable default and a convenient shorthand. Unless I missed something, implementing these commands required reimplementing LabelCommand.handle with the default hard coded in. Obviously violates DRY.


  1. Add field "default_label" to LabelCommand with value "None"
  2. Switch (line 317-318 in django/trunk/django/core/management/
if not labels:
    raise CommandError('Enter at least one %s.' % self.label)


if not labels:
    if not self.default_label
        raise CommandError('Enter at least one %s.' % self.label)
        labels = [self.default_label]

or something similar.

Patch is attached.

Attachments (1)

LabelCommand_default_label.diff (692 bytes) - added by maaku 9 years ago.
patch against SVN

Download all attachments as: .zip

Change History (9)

Changed 9 years ago by maaku

patch against SVN

comment:1 Changed 9 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:2 Changed 9 years ago by maaku

Checking in on the status of this patch...

The ticket was accepted 3 months ago, it has a patch, and does not need further improvement, documentation, or tests. However it is still not in SVN. Forgive my ignorance, but is there anything I need to do to move this along?

comment:3 Changed 8 years ago by James Bennett

milestone: 1.2

1.2 is feature-frozen, moving this feature request off the milestone.

comment:4 Changed 7 years ago by Julien Phalip

Severity: Normal
Type: New feature

comment:5 Changed 7 years ago by Julien Phalip

Needs documentation: set
Needs tests: set

comment:6 Changed 6 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:7 Changed 6 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:8 Changed 4 years ago by Claude Paroz

Resolution: wontfix
Status: newclosed

Considering the time this ticket is open without anyone adding tests and documentation, I'll close it as won't fix. As for me, inheriting from BaseCommand and implementing your custom code is the way to go.

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