Opened 5 years ago

Last modified 3 years ago

#11590 new New feature

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 5 years ago.
patch against SVN

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by maaku

patch against SVN

comment:1 Changed 5 years ago by Alex

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

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

  • milestone 1.2 deleted

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

comment:4 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 3 years ago by julien

  • Needs documentation set
  • Needs tests set

comment:6 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

Add Comment

Modify Ticket

Change Properties
<Author field>
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.