Re: [Django] #31924: Support --force-color for runserver

22 views
Skip to first unread message

Django

unread,
Aug 25, 2020, 6:31:03 AM8/25/20
to django-...@googlegroups.com
#31924: Support --force-color for runserver
-------------------------------------+-------------------------------------
Reporter: Zach Waggoner | Owner: nobody
Type: New feature | Status: closed
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
runserver,force_color | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* resolution: => invalid


Comment:

It already works properly, you just need to set the `DJANGO_COLORS`
environment variable to reach `ServerFormatter`, see
[https://docs.djangoproject.com/en/3.1/ref/django-admin/#syntax-coloring
docs].

--
Ticket URL: <https://code.djangoproject.com/ticket/31924#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 25, 2020, 9:42:38 AM8/25/20
to django-...@googlegroups.com
#31924: Support --force-color for runserver
-------------------------------------+-------------------------------------
Reporter: Zach Waggoner | Owner: nobody
Type: New feature | Status: closed
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
runserver,force_color | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Zach Waggoner):

Replying to [comment:1 felixxm]:


> It already works properly, you just need to set the `DJANGO_COLORS`
environment variable to reach `ServerFormatter`, see
[https://docs.djangoproject.com/en/3.1/ref/django-admin/#syntax-coloring
docs].

I might be missing something, but that doesn't work for me. As an example,
trying to run this Procfile through honcho does not preserve the color
output:

{{{
web: DJANGO_COLORS=dark python server/manage.py runserver
}}}

and neither does:

{{{
web: DJANGO_COLORS=dark python server/manage.py runserver --force-color
}}}

This is on Django 3.1.

--
Ticket URL: <https://code.djangoproject.com/ticket/31924#comment:2>

Django

unread,
Aug 25, 2020, 2:44:12 PM8/25/20
to django-...@googlegroups.com
#31924: Support --force-color for runserver
-------------------------------------+-------------------------------------
Reporter: Zach Waggoner | Owner: nobody
Type: New feature | Status: closed
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
runserver,force_color | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by felixxm):

It looks that Django doesn't recognize that your system's terminal
supports color, we have an open ticket to improve detection on Windows,
see #31216. You may also fake the installation of `ANSICON` by setting the
appropriate environmental variable, `ANSICON="on"`. Please use one of
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels].

--
Ticket URL: <https://code.djangoproject.com/ticket/31924#comment:3>

Django

unread,
Aug 25, 2020, 4:39:25 PM8/25/20
to django-...@googlegroups.com
#31924: Support --force-color for runserver
-------------------------------------+-------------------------------------
Reporter: Zach Waggoner | Owner: nobody
Type: New feature | Status: closed
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
runserver,force_color | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Zach Waggoner:

Old description:

> Currently, the `--force-color` option doesn't work for the `runserver`
> management command. In my own experimentation, I was able to force color
> output by changing `self.style = color_style()` to `self.style =
> color_style(force_color=True)` in django.utils.log.ServerFormatter. I can
> of course achieve this by using my own django.server formatter class, but
> it would be convenient to have it built in.

New description:

Currently, the `--force-color` option doesn't work for the `runserver`
management command. In my own experimentation, I was able to force color
output by changing `self.style = color_style()` to `self.style =
color_style(force_color=True)` in `django.utils.log.ServerFormatter`. I
can of course achieve this by using my own django.server formatter class,
but it would be convenient to have it built in.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31924#comment:5>

Reply all
Reply to author
Forward
0 new messages