* type: Bug => Cleanup/optimization
* easy: 0 => 1
* stage: Unreviewed => Accepted
Comment:
It seems reasonable, to make it customizable by passing via `kwargs` to
the [https://docs.djangoproject.com/en/4.0/howto/custom-management-
commands/#django.core.management.BaseCommand.create_parser
BaseCommand.create_parser() (as documented)]:
{{{#!diff
diff --git a/django/core/management/base.py
b/django/core/management/base.py
index f0e711ac76..52407807d8 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -286,10 +286,10 @@ class BaseCommand:
Create and return the ``ArgumentParser`` which will be used to
parse the arguments to this command.
"""
+ kwargs.setdefault("formatter_class", DjangoHelpFormatter)
parser = CommandParser(
prog="%s %s" % (os.path.basename(prog_name), subcommand),
description=self.help or None,
- formatter_class=DjangoHelpFormatter,
missing_args_message=getattr(self, "missing_args_message",
None),
called_from_command_line=getattr(self,
"_called_from_command_line", None),
**kwargs,
}}}
What do you think?
--
Ticket URL: <https://code.djangoproject.com/ticket/33657#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.