I would suggest to adapt this behavior and also return this output from
`execute` (and consequently by `call_command` so we can easily get access
to this result from `call_command`). The behavior when calling the command
by the command line would be unchanged.
I even thought about not writing this result to `self.stdout` when the
command is called by `call_command`, but this would be backwards
incompatible and I don't see a good deprecation path for this.
--
Ticket URL: <https://code.djangoproject.com/ticket/26190>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by timgraham):
Would this be an alternative to the currently documented method of:
{{{
with open('/path/to/command_output') as f:
management.call_command('dumpdata', stdout=f)
}}}
or is there some other difference?
--
Ticket URL: <https://code.djangoproject.com/ticket/26190#comment:1>
Comment (by claudep):
Only the return value of the command `handle()` method would be returned
from `call_command`.
In the current Django commands, only the following are returning some
content: diffsettings, sqlflush, sqlmigrate, sqlsequencereset,
changepassword (success message), findstatic. Other commands are calling
`self.stdout.write` during the processing of the command.
To get all the content output by a command, you still have to provide a
catcher in the sdtout argument as you mentioned.
--
Ticket URL: <https://code.djangoproject.com/ticket/26190#comment:2>
* stage: Unreviewed => Accepted
Comment:
I guess I don't have any objections other than I always found the return
value of `handle()` to be somewhat inconsistent and ill-defined as to when
that should be preferred instead of having the `handle()` method itself do
the logging.
--
Ticket URL: <https://code.djangoproject.com/ticket/26190#comment:3>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/6139 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/26190#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/26190#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"b46c0ea6c87f006f9ef0ccc5d8c0fa2445fb4156" b46c0ea6]:
{{{
#!CommitTicketReference repository=""
revision="b46c0ea6c87f006f9ef0ccc5d8c0fa2445fb4156"
Fixed #26190 -- Returned handle() result from call_command
Thanks Tim Graham for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26190#comment:6>
Comment (by Claude Paroz <claude@…>):
In [changeset:"269b5f262cef88cb595b21a76e707b41ee4ed627" 269b5f2]:
{{{
#!CommitTicketReference repository=""
revision="269b5f262cef88cb595b21a76e707b41ee4ed627"
Used call_command return value in staticfiles tests
Refs #26190.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26190#comment:7>