The code treats it as output, and writes it to self.stdout(). This should
be documented.
(Note: the behavior changed slightly between 1.4 and 1.8: In 1.4, we
returned a binary string, and it worked fine, in 1.8, this fails with a
DecodeError because of "results.endswith(ending)" ).
--
Ticket URL: <https://code.djangoproject.com/ticket/25515>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: rene@… (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25515#comment:1>
* has_patch: 0 => 1
* stage: Unreviewed => Accepted
Comment:
Good enough?
{{{ #!diff
diff --git a/docs/howto/custom-management-commands.txt b/docs/howto
/custom-management-commands.txt
index f42680b..0430a60 100644
--- a/docs/howto/custom-management-commands.txt
+++ b/docs/howto/custom-management-commands.txt
@@ -300,6 +300,9 @@ the :meth:`~BaseCommand.handle` method must be
implemented.
The actual logic of the command. Subclasses must implement this
method.
+ The method may return a string which will be printed to ``stdout``
(wrapped
+ by ``BEGIN;`` and ``COMMIT;`` if :attr:`output_transaction` is
``True``).
+
.. method:: BaseCommand.check(app_configs=None, tags=None,
display_num_errors=False)
Uses the system check framework to inspect the entire Django project
for
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25515#comment:2>
Comment (by nedbatchelder):
Even better: mention that it's a Unicode string. I stumbled on all this
due to a UnicodeDecodeError from a bytestring being returned.
--
Ticket URL: <https://code.djangoproject.com/ticket/25515#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"3f766d44c5ea000ecf47829ca565b1921dab2ac1" 3f766d44]:
{{{
#!CommitTicketReference repository=""
revision="3f766d44c5ea000ecf47829ca565b1921dab2ac1"
Fixed #25515 -- Documented the return value of BaseCommand.handle()
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25515#comment:4>
Comment (by Tim Graham <timograham@…>):
In [changeset:"d81b0812d43b8c068c8e65b19c1fa9dbdcb1da47" d81b0812]:
{{{
#!CommitTicketReference repository=""
revision="d81b0812d43b8c068c8e65b19c1fa9dbdcb1da47"
[1.9.x] Fixed #25515 -- Documented the return value of
BaseCommand.handle()
Backport of 3f766d44c5ea000ecf47829ca565b1921dab2ac1 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25515#comment:5>
Comment (by Tim Graham <timograham@…>):
In [changeset:"9be9c511cc9f552a34367427aaac3bdc0fdb88fc" 9be9c511]:
{{{
#!CommitTicketReference repository=""
revision="9be9c511cc9f552a34367427aaac3bdc0fdb88fc"
[1.8.x] Fixed #25515 -- Documented the return value of
BaseCommand.handle()
Backport of 3f766d44c5ea000ecf47829ca565b1921dab2ac1 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25515#comment:6>