Opened 11 years ago

Closed 10 years 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: dev
Severity: Normal Keywords: call_command, docs
Cc: Areski Belaid Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

e.g.

./manage.py 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 by Preston Holmes, 11 years ago

Triage Stage: UnreviewedAccepted

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 by leftmoose, 11 years ago

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:4 by Preston Holmes, 11 years ago

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 by Tim Graham, 11 years ago

Component: DocumentationCore (Management commands)

comment:6 by Claude Paroz, 10 years ago

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

comment:7 by Areski Belaid, 10 years ago

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 https://github.com/django/django/pull/3040

comment:8 by Areski Belaid, 10 years ago

Cc: Areski Belaid added

comment:9 by Tim Graham, 10 years ago

Resolution: duplicate
Status: newclosed
Summary: call_command optionscall_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