What I'd like to have is basically the other side of the coin: a `--force-
colors` flag that instructs Django to output ANSI color sequences in cases
it would disable colors by default (typically, when the output is piped to
another command, as documented).
My real world use-case is the following one: I have a custom Django
command to import data. I run this command myself, and I'd like to send a
colored log (HTML seems perfect for this) to the data curators. I can use
the https://github.com/theZiz/aha utility for this, but that doesn't work
since Django disable colors when the output is piped.
Other *nix commands have a special flag for this exact use-case, for
example `$ ls --color=always`
--
Ticket URL: <https://code.djangoproject.com/ticket/29560>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Carlton Gibson (added)
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted
Comment:
Hi Nicolas. I'm going to Accept this: it seems reasonable.
> …in cases it would disable colors by default (typically, when the output
is piped to another command, as documented).
Can I ask, where is this documented? I cannot seem to find it. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:1>
Comment (by Nicolas Noé):
Thanks Carlton!
It is documented in https://docs.djangoproject.com/en/2.0/ref/django-admin
/#syntax-coloring:
''The django-admin / manage.py commands will use pretty color-coded output
if your terminal supports ANSI-colored output. It won’t use the color
codes if you’re piping the command’s output to another program.''
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:2>
Comment (by Carlton Gibson):
Thanks Nicolas. I just found that. (I must have been blind: I even looked
in that exact location... sigh :-)
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:3>
* owner: nobody => Nicolas Noé
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:4>
* status: assigned => new
* owner: Nicolas Noé => (none)
Comment:
I unfortunately can't find time in the short term to work on the
implementation...
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:5>
* owner: (none) => Hasan Ramezani
* status: new => assigned
* has_patch: 0 => 1
Comment:
PR[https://github.com/django/django/pull/10213]
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:6>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:7>
* stage: Accepted => Ready for checkin
Comment:
This looks good to me. (I had a couple of tiny comment which I assume will
be addressed, so progressing.) Thanks Hasan.
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"5195b99e2c3804ec5f9c98d29e0cf76bf44b0cec" 5195b99e]:
{{{
#!CommitTicketReference repository=""
revision="5195b99e2c3804ec5f9c98d29e0cf76bf44b0cec"
Fixed #29560 -- Added --force-color management command option.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:8>
Comment (by Tim Graham <timograham@…>):
In [changeset:"a4d8e412e0295ac7d40bb87ee6e5f44649f97816" a4d8e412]:
{{{
#!CommitTicketReference repository=""
revision="a4d8e412e0295ac7d40bb87ee6e5f44649f97816"
Refs #29560 -- Fixed typo in django/core/management/base.py.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29560#comment:9>