summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorElena Oat <elena@rategia.com>2015-11-08 10:47:21 +0100
committerTim Graham <timograham@gmail.com>2015-11-17 18:25:08 -0500
commita9f1ea32750be33385d7ba014f9ed63d6ee695d6 (patch)
tree7e68967eaf40764c90a7eee7a1496d745cf7b62b /docs
parentb4aa38d106e903a21773d3486885fd8d2fa8a660 (diff)
[1.8.x] Fixed #25526 -- Documented how to output colored text in custom management commands.
Backport of d26207d56cab21e3767121d53ebaddbbfc78a4ce from master
Diffstat (limited to 'docs')
-rw-r--r--docs/howto/custom-management-commands.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt
index 4e55111b81..fb091d2866 100644
--- a/docs/howto/custom-management-commands.txt
+++ b/docs/howto/custom-management-commands.txt
@@ -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
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
-------