Opened 6 years ago

Closed 16 months 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 6 years ago.
patch against SVN

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by maaku

patch against SVN

comment:1 Changed 6 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 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 6 years ago by ubernostrum

  • milestone 1.2 deleted

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

comment:4 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 4 years ago by julien

  • Needs documentation set
  • Needs tests set

comment:6 Changed 4 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 4 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:8 Changed 16 months ago by claudep

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

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