mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
[1.5.x] Fixed #19749 -- Documented ending param to command's self.stdout/err
Thanks xian at mintchaos.com for the report.
Backport of 0201b9d6d
from master
This commit is contained in:
parent
15796db507
commit
2d53799ca6
2 changed files with 12 additions and 1 deletions
|
@ -65,12 +65,18 @@ look like this:
|
|||
|
||||
self.stdout.write('Successfully closed poll "%s"' % poll_id)
|
||||
|
||||
.. _management-commands-output:
|
||||
|
||||
.. note::
|
||||
When you are using management commands and wish to provide console
|
||||
output, you should write to ``self.stdout`` and ``self.stderr``,
|
||||
instead of printing to ``stdout`` and ``stderr`` directly. By
|
||||
using these proxies, it becomes much easier to test your custom
|
||||
command.
|
||||
command. Note also that you don't need to end messages with a newline
|
||||
character, it will be added automatically, unless you specify the ``ending``
|
||||
parameter::
|
||||
|
||||
self.stdout.write("Unterminated line", ending='')
|
||||
|
||||
The new custom command can be called using ``python manage.py closepoll
|
||||
<poll_id>``.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue