Ticket #19749: 19749-2.diff

File 19749-2.diff, 1.7 KB (added by Claude Paroz, 12 years ago)

Mention the ending parameter

  • docs/howto/custom-management-commands.txt

    diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt
    index bfcea64..7a31fc4 100644
    a b look like this:  
    6565
    6666                self.stdout.write('Successfully closed poll "%s"' % poll_id)
    6767
     68.. _management-commands-output:
     69
    6870.. note::
    6971    When you are using management commands and wish to provide console
    7072    output, you should write to ``self.stdout`` and ``self.stderr``,
    7173    instead of printing to ``stdout`` and ``stderr`` directly. By
    7274    using these proxies, it becomes much easier to test your custom
    73     command.
     75    command. Note also that you don't need to end messages with a newline
     76    character, it will be added automatically, unless you specify the ``ending``
     77    parameter::
     78
     79        self.stdout.write("Unterminated line", ending='')
    7480
    7581The new custom command can be called using ``python manage.py closepoll
    7682<poll_id>``.
  • docs/releases/1.5.txt

    diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
    index a5ce08a..03e4855 100644
    a b Django 1.5 also includes several smaller improvements worth noting:  
    253253  from :ref:`call_command <call-command>`. Any exception raised by the command
    254254  (mostly :ref:`CommandError <ref-command-exceptions>`) is propagated.
    255255
     256  Moreover, when you output errors or messages in your custom commands, you
     257  should now use ``self.stdout.write('message')`` and
     258  ``self.stderr.write('error')`` (see the note on
     259  :ref:`management commands output <management-commands-output>`).
     260
    256261* The dumpdata management command outputs one row at a time, preventing
    257262  out-of-memory errors when dumping large datasets.
    258263
Back to Top