mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
[1.8.x] Fixed #25526 -- Documented how to output colored text in custom management commands.
Backport of d26207d56cab21e3767121d53ebaddbbfc78a4ce from master
This commit is contained in:
parent
b4aa38d106
commit
a9f1ea3275
@ -320,6 +320,21 @@ All attributes can be set in your derived class and can be used in
|
|||||||
because attempting to set the locale needs access to settings. This
|
because attempting to set the locale needs access to settings. This
|
||||||
condition will generate a :class:`CommandError`.
|
condition will generate a :class:`CommandError`.
|
||||||
|
|
||||||
|
.. attribute:: BaseCommand.style
|
||||||
|
|
||||||
|
An instance attribute that helps create colored output when writing to
|
||||||
|
``stdout`` or ``stderr``. For example::
|
||||||
|
|
||||||
|
self.stdout.write(self.style.NOTICE('...'))
|
||||||
|
|
||||||
|
See :ref:`syntax-coloring` to learn how to modify the color palette and to
|
||||||
|
see the available styles (use uppercased versions of the "roles" described
|
||||||
|
in that section).
|
||||||
|
|
||||||
|
If you pass the :djadminopt:`--no-color` option when running your
|
||||||
|
command, all ``self.style()`` calls will return the original string
|
||||||
|
uncolored.
|
||||||
|
|
||||||
Methods
|
Methods
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user