Refs #19973 -- Removed optparse support in management commands per deprecation timeline.

This commit is contained in:
Tim Graham 2015-08-18 12:46:03 -04:00
parent 3bbebd06ad
commit 6a70cb5397
8 changed files with 47 additions and 209 deletions

View file

@ -69,16 +69,6 @@ look like this::
self.stdout.write('Successfully closed poll "%s"' % poll_id)
.. versionchanged:: 1.8
Before Django 1.8, management commands were based on the :py:mod:`optparse`
module, and positional arguments were passed in ``*args`` while optional
arguments were passed in ``**options``. Now that management commands use
:py:mod:`argparse` for argument parsing, all arguments are passed in
``**options`` by default, unless you name your positional arguments to
``args`` (compatibility mode). You are encouraged to exclusively use
``**options`` for new commands.
.. _management-commands-output:
.. note::
@ -128,12 +118,6 @@ options can be added in the :meth:`~BaseCommand.add_arguments` method like this:
poll.delete()
# ...
.. versionchanged:: 1.8
Previously, only the standard :py:mod:`optparse` library was supported and
you would have to extend the command ``option_list`` variable with
``optparse.make_option()``.
The option (``delete`` in our example) is available in the options dict
parameter of the handle method. See the :py:mod:`argparse` Python documentation
for more about ``add_argument`` usage.
@ -227,19 +211,6 @@ Attributes
All attributes can be set in your derived class and can be used in
:class:`BaseCommand`s :ref:`subclasses<ref-basecommand-subclasses>`.
.. attribute:: BaseCommand.args
A string listing the arguments accepted by the command,
suitable for use in help messages; e.g., a command which takes
a list of application names might set this to '<app_label
app_label ...>'.
.. deprecated:: 1.8
This should be done now in the :meth:`~BaseCommand.add_arguments()`
method, by calling the ``parser.add_argument()`` method. See the
``closepoll`` example above.
.. attribute:: BaseCommand.can_import_settings
A boolean indicating whether the command needs to be able to
@ -261,17 +232,6 @@ All attributes can be set in your derived class and can be used in
the message error returned in the case of missing arguments. The default is
output by :py:mod:`argparse` ("too few arguments").
.. attribute:: BaseCommand.option_list
This is the list of ``optparse`` options which will be fed
into the command's ``OptionParser`` for parsing arguments.
.. deprecated:: 1.8
You should now override the :meth:`~BaseCommand.add_arguments` method
to add custom arguments accepted by your command. See :ref:`the example
above <custom-commands-options>`.
.. attribute:: BaseCommand.output_transaction
A boolean indicating whether the command outputs SQL statements; if