argparse
is the tool Django (allegedly) uses for parsing the command line, as per this commit and this support ticket.
However, nine months have passed now, and when I visit the BaseCommand
declaration I see:
from optparse import make_option, OptionParser
...
option_list = (
make_option('-v', '--verbosity', action='store', dest='verbosity', default='1',
type='choice', choices=['0', '1', '2', '3'],
help='Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output'),
make_option('--settings',
help='The Python path to a settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.'),
make_option('--pythonpath',
help='A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".'),
make_option('--traceback', action='store_true',
help='Raise on exception'),
make_option('--no-color', action='store_true', dest='no_color', default=False,
help="Don't colorize the command output."),
)
When will Django use argparse
in 1.7?
The commit you link to is tagged for v1.8b2. Looking at the source code for the stable v1.7.x and v1.8.x branches it looks like argparse
will be introduced as the default in v1.8. See also the release notes for v1.8.
However, optparse
will remain as a fallback option (to allow continued support for Python versions prior to 2.7/3.2) until Django v2. According to the test source code:
optparse
should be supported during Django 1.8/1.9 releases