[Fixed]-Django runserver color output

9👍

This is the default palette:

    'ERROR':        { 'fg': 'red', 'opts': ('bold',) },
    'NOTICE':       { 'fg': 'red' },
    'SQL_FIELD':    { 'fg': 'green', 'opts': ('bold',) },
    'SQL_COLTYPE':  { 'fg': 'green' },
    'SQL_KEYWORD':  { 'fg': 'yellow' },
    'SQL_TABLE':    { 'opts': ('bold',) },
    'HTTP_INFO':         { 'opts': ('bold',) },
    'HTTP_SUCCESS':      { },
    'HTTP_REDIRECT':     { 'fg': 'green' },
    'HTTP_NOT_MODIFIED': { 'fg': 'cyan' },
    'HTTP_BAD_REQUEST':  { 'fg': 'red', 'opts': ('bold',) },
    'HTTP_NOT_FOUND':    { 'fg': 'yellow' },
    'HTTP_SERVER_ERROR': { 'fg': 'magenta', 'opts': ('bold',) },

7👍

Haven’t done it by myself, but here are some links which will help:

Basically, colors are set via DJANGO_COLORS environment variable:

export DJANGO_COLORS="light"
👤alecxe

2👍

To add a bit more to Pavel’s answer, here is the location of the file that contains the default color settings on a Mac (OSX 10.11 El Capitan). Note: this is for Django 1.9.

The color palette is located in a file called: termcolors.py, which is located in:

/django/utils/

I installed Django in a virtual environment (“venv1”), so for me, the termcolors.py file is located here:

~/.virtualenvs/venv1/lib/python3.4/site-packages/django/utils/termcolors.py

Leave a comment