Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django runserver color output

I am looking for an answer concerning the color used in the output during a session of python2 manage.py runserver

I'm sure that understanding why some output is yellow, blue, or pink will help me to perform better debugging.

like image 648
tbenett Avatar asked Aug 06 '13 11:08

tbenett


3 Answers

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',) },
like image 100
Pavel Anossov Avatar answered Oct 18 '22 11:10

Pavel Anossov


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

  • django docs on django-admin commands coloring
  • Better color scheme for django dev server
  • Change colors of output log text from Django development server

Basically, colors are set via DJANGO_COLORS environment variable:

export DJANGO_COLORS="light"
like image 30
alecxe Avatar answered Oct 18 '22 10:10

alecxe


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
like image 26
someguyinafloppyhat Avatar answered Oct 18 '22 10:10

someguyinafloppyhat