mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #34140 -- Reformatted code blocks in docs with blacken-docs.
This commit is contained in:
parent
6015bab80e
commit
14459f80ee
193 changed files with 5797 additions and 4481 deletions
|
@ -2097,9 +2097,9 @@ Examples::
|
|||
from django.core import management
|
||||
from django.core.management.commands import loaddata
|
||||
|
||||
management.call_command('flush', verbosity=0, interactive=False)
|
||||
management.call_command('loaddata', 'test_data', verbosity=0)
|
||||
management.call_command(loaddata.Command(), 'test_data', verbosity=0)
|
||||
management.call_command("flush", verbosity=0, interactive=False)
|
||||
management.call_command("loaddata", "test_data", verbosity=0)
|
||||
management.call_command(loaddata.Command(), "test_data", verbosity=0)
|
||||
|
||||
Note that command options that take no arguments are passed as keywords
|
||||
with ``True`` or ``False``, as you can see with the ``interactive`` option above.
|
||||
|
@ -2107,14 +2107,14 @@ with ``True`` or ``False``, as you can see with the ``interactive`` option above
|
|||
Named arguments can be passed by using either one of the following syntaxes::
|
||||
|
||||
# Similar to the command line
|
||||
management.call_command('dumpdata', '--natural-foreign')
|
||||
management.call_command("dumpdata", "--natural-foreign")
|
||||
|
||||
# Named argument similar to the command line minus the initial dashes and
|
||||
# with internal dashes replaced by underscores
|
||||
management.call_command('dumpdata', natural_foreign=True)
|
||||
management.call_command("dumpdata", natural_foreign=True)
|
||||
|
||||
# `use_natural_foreign_keys` is the option destination variable
|
||||
management.call_command('dumpdata', use_natural_foreign_keys=True)
|
||||
management.call_command("dumpdata", use_natural_foreign_keys=True)
|
||||
|
||||
Some command options have different names when using ``call_command()`` instead
|
||||
of ``django-admin`` or ``manage.py``. For example, ``django-admin
|
||||
|
@ -2125,7 +2125,7 @@ passed to ``parser.add_argument()``.
|
|||
|
||||
Command options which take multiple options are passed a list::
|
||||
|
||||
management.call_command('dumpdata', exclude=['contenttypes', 'auth'])
|
||||
management.call_command("dumpdata", exclude=["contenttypes", "auth"])
|
||||
|
||||
The return value of the ``call_command()`` function is the same as the return
|
||||
value of the ``handle()`` method of the command.
|
||||
|
@ -2136,5 +2136,5 @@ Output redirection
|
|||
Note that you can redirect standard output and error streams as all commands
|
||||
support the ``stdout`` and ``stderr`` options. For example, you could write::
|
||||
|
||||
with open('/path/to/command_output', 'w') as f:
|
||||
management.call_command('dumpdata', stdout=f)
|
||||
with open("/path/to/command_output", "w") as f:
|
||||
management.call_command("dumpdata", stdout=f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue