#29560 closed New feature (fixed)
Add an option to django-admin to always colorize output
Reported by: | Nicolas Noé | Owned by: | Hasan Ramezani |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Carlton Gibson | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
With Django management commands, it is currently possible disable colors with the --no-colors
flag.
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
Change History (9)
comment:1 by , 6 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
comment:2 by , 6 years ago
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.
comment:3 by , 6 years ago
Thanks Nicolas. I just found that. (I must have been blind: I even looked in that exact location... sigh :-)
comment:4 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 6 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
I unfortunately can't find time in the short term to work on the implementation...
comment:6 by , 6 years ago
Has patch: | set |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:7 by , 6 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
This looks good to me. (I had a couple of tiny comment which I assume will be addressed, so progressing.) Thanks Hasan.
Hi Nicolas. I'm going to Accept this: it seems reasonable.
Can I ask, where is this documented? I cannot seem to find it. Thanks.