Opened 3 years ago

Closed 16 months ago

#19570 closed Cleanup/optimization (duplicate)

call_command option kwargs differ from command line options

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


when used with call_command, certain management commands use keywords differing from the command line options,


./ flush --no-initial-data

needs to be called with

call_command('flush', load_initial_data=False)

Maybe the docs (for call_command) should be updated to reflect this. (Though not sure what advice to give beyond "read the source"). Alternatively, we chould add notes to each option where the names differ, but that seems messy.

Change History (9)

comment:1 Changed 3 years ago by ptone

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

At a minimum - this should be documented.

A more complete patch might attempt to support all command line options for builtin commands with the pattern of dashes replaced with underscores.

comment:2 Changed 3 years ago by leftmoose

currently not matching options

command        command line arg      option.dest

syncdb         --noinput             interactive
syncdb         --no-initial-data     load_initial_data
dumpdata       --natural             use_natural_keys
dumpdata       --all                 use_base_manager
testserver     --noinput             interactive
testserver     --ipv6                use_ipv6
templates      --extension           extensions
templates      --name                files
startproject   --extension           extensions
startproject   --name                files
flush          --noinput             interactive
flush          --no-initial-data     load_initial_data
startapp       --extension           extensions
startapp       --name                files
makemessages   --extension           extensions
makemessages   --ignore              ignore_patterns
makemessages   --no-default-ignore   use_default_ignore_patterns
loaddata       --ignorenonexistent   ignore
runserver      --ipv6                use_ipv6
runserver      --nothreading         use_threading
runserver      --noreload            use_reloader
test           --noinput             interactive

comment:3 Changed 3 years ago by leftmoose

  • Has patch set

comment:4 Changed 3 years ago by ptone

  • Needs documentation set

If we are going with the full mapping - this will need to be documented. I wouldn't deprecate the original kwargs, but only document the ones that match the CLI options and describe the - to _ pattern, maybe note that some commands have some legacy analogs - not entirely sure about that last bit though.

comment:5 Changed 3 years ago by timo

  • Component changed from Documentation to Core (Management commands)

comment:6 Changed 16 months ago by claudep

I guess the patch I proposed for #22985 would solve this issue, too.

comment:7 Changed 16 months ago by areski

I was also working on different approach to solve this ticket which might now become irrelevant with claudep fix.

I still leave the PR for interest maybe some of you would still want to see more consistency with the option names.
Here it is

comment:8 Changed 16 months ago by areski

  • Cc areski added

comment:9 Changed 16 months ago by timgraham

  • Resolution set to duplicate
  • Status changed from new to closed
  • Summary changed from call_command options to call_command option kwargs differ from command line options

Marking as a duplicate given Claude's fix.

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