Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Python 3 support #339

jleclanche opened this Issue · 13 comments

I searched the issues and didn't see any about the status of python 3 support.

Here are the current errors on pip install (on 22ebebd) when running in a 1.5 python3 environment:

Installing collected packages: django-debug-toolbar
  Running install for django-debug-toolbar

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/management/commands/", line 17
        print sqlparse.format(raw_sql, reindent=True),
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/toolbar/", line 96
        except ImportError, e:
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/utils/sqlparse/", line 82
        except Exception, err:
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/utils/sqlparse/", line 155
        print '%s%s%d %s \'%s\'' % (indent, pre, idx,
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/utils/tracking/", line 40
        except Exception, e:
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/", line 6
        except Exception, e:
    SyntaxError: invalid syntax

We should start discussion about python 3 support.

Supported python versions

There is no information about which python versions does django-debug-toolbar support. The most important question is if we can drop support for versions lower than 2.6. Supporting python 2.5 would make it painful (eg. except syntax).

Supported django versions

Django 1.4.2 comes with django.utils.six and some additional compatibility code for python 3 support. Question is - can we drop support for django < 1.4.2, or we should use external six library? Also, it is possible that we would have to include a bit more compatibility code.


I believe, python 2.5 can be dropped, as django is dropping it in 1.5.
Dropping django < 1.4.2 support is arguable, but I'd prefer movig forward, because python 2 will eventually become history.

@jezdez jezdez closed this
@jezdez jezdez reopened this

Woops, sorry.


I have been testing debug toolbar under python 3 , so far after running it through 2to3 not a lot of issues during usage, except sqlpanel injection and some tests failed after 2to3 as well (mostly related to tracking injection).
Because in Python 3 unbound methods are just functions, debug_toolbar.utils._replace_function does not work properly.
My temporary fix was smth like:

def _replace_function(func, wrapped, klass=None):
    if getattr(klass, func.__name__, None):
        setattr(klass, func.__name__, wrapped)
    elif isinstance(func, types.FunctionType):

Not very nice but did the trick, as far as I could find, there seems to be no way to get class from unbound method.
Hopefully I am missing something.

Some backwards compatibility code will be required but technically if we drop django < 1.4.2 it should be no problem.
Although, I don't want to drop python 2.5, as it breaks compatibility with older versions of django.
(Someone might be running 1.4.* with python 2.5)

I don't mind a separate/future version, that works with same Python versions as django 1.5 (2.6,2.7,3.2, 3.3) thus supports only 1.5


Can anybody please tell me if they have a at least partially working port of django-debug-toolbar for Python 3? And if so can I have a copy?


If anyone is interested, please take a look at #373


+1 Waiting for this :(




Is there a way I can get your debug toolbar working with Python3 ? =)


To those waiting for Python 3 support: I have been using this fork with no issues.


Maybe you could do a pull request ?


Closing is favor of #412.

@aaugustin aaugustin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.