orf / django-debug-toolbar-template-timings

A django-debug-toolbar panel that displays template rendering times for your Django application
https://pypi.python.org/pypi/django-debug-toolbar-template-timings
MIT License
296 stars 28 forks source link

Python 3 compatibility #18

Closed maiksprenger closed 10 years ago

maiksprenger commented 10 years ago

I just investigated Python 3 compatibility in Oscar (https://github.com/tangentlabs/django-oscar/issues/780). The template timings panel unfortunately currently fails when trying to open any URLs with the development server.

Stacktrace

Any plans to support it?

orf commented 10 years ago

I personally don't use Python 3 but I guess I have to take the plunge some time, it might as well be with this. I will add support for Python 3 and some other misc stuff (like making enabling/disabling the panel actually do something) near the end of this month.

AntelopeSalad commented 10 years ago

I'm a newcomer to Python but I managed to get it working in Python 3 with very little tinkering but I'm not sure if the values are accurate. Here's what I did to get it to actually run:

I changed these 2 values from None to 0.

https://github.com/orf/django-debug-toolbar-template-timings/blob/master/template_timings_panel/panels/TemplateTimings.py#L93-94

So that snippet now looks like:

        results.timings.setdefault(key, {})[name_self] = {
            'count': 0,
            'min': 0,
            'max': 0,
            'total': 0,
            'avg': 0,
            'is_base': False,
            'queries': 0,
            'query_duration': 0
        }

I don't want to send a pull request because I didn't run it past any tests. All I know is that it no longer throws an error using Python 3.3.2 and it seems to have timing values for the templates.

@orf, is this the proper fix?

orf commented 10 years ago

I think so @AntelopeSalad, thanks! I will add this soon :)

orf commented 10 years ago

@maikhoepfel I have pushed a new release out (0.6), it should support Python 3 + enabling/disabling of the panel. Let me know if you run into any problems with it.

maiksprenger commented 10 years ago

@orf Thanks a bunch! Will add it again once we do our next speed runs :)