Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fixed #19749 -- Documented ending param to command's self.std…

…out/err

Thanks xian at mintchaos.com for the report.
Backport of 0201b9d from master
  • Loading branch information...
commit 2d53799ca6674de39b5d3ac66c28b434d079725c 1 parent 15796db
Claude Paroz authored February 09, 2013
8  docs/howto/custom-management-commands.txt
@@ -65,12 +65,18 @@ look like this:
65 65
 
66 66
                 self.stdout.write('Successfully closed poll "%s"' % poll_id)
67 67
 
  68
+.. _management-commands-output:
  69
+
68 70
 .. note::
69 71
     When you are using management commands and wish to provide console
70 72
     output, you should write to ``self.stdout`` and ``self.stderr``,
71 73
     instead of printing to ``stdout`` and ``stderr`` directly. By
72 74
     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='')
74 80
 
75 81
 The new custom command can be called using ``python manage.py closepoll
76 82
 <poll_id>``.
5  docs/releases/1.5.txt
@@ -253,6 +253,11 @@ Django 1.5 also includes several smaller improvements worth noting:
253 253
   from :ref:`call_command <call-command>`. Any exception raised by the command
254 254
   (mostly :ref:`CommandError <ref-command-exceptions>`) is propagated.
255 255
 
  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
+
256 261
 * The dumpdata management command outputs one row at a time, preventing
257 262
   out-of-memory errors when dumping large datasets.
258 263
 

0 notes on commit 2d53799

Please sign in to comment.
Something went wrong with that request. Please try again.