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
297 stars 28 forks source link

template timings section is empty in debug toolbar panel #39

Open kushagra219 opened 4 years ago

kushagra219 commented 4 years ago

This is my settings.py part for the django-debug-toolbar and django-debug-toolbar-template-timings, but all the sections are displaying something in toolbar except template-timings which was really required as one of my templates is taking too much time to load and I can't figure out why! how can I rectify this issue?

Screenshot (165)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ALLOWED_HOSTS = ['*']

INTERNAL_IPS = [
    '127.0.0.1',
]

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    # 'rest_framework.authtoken',
    'django_filters',
    'store',
    'app',
    'debug_toolbar',
    'template_timings_panel',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    # 'store.middlewares.auth.auth_middleware'
]

ROOT_URLCONF = 'Eshop.urls'

DEBUG_TOOLBAR_PANELS = [
    'debug_toolbar.panels.versions.VersionsPanel',
    'debug_toolbar.panels.timer.TimerPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeadersPanel',
    'debug_toolbar.panels.request.RequestPanel',
    'debug_toolbar.panels.sql.SQLPanel',
    'debug_toolbar.panels.staticfiles.StaticFilesPanel',
    'debug_toolbar.panels.templates.TemplatesPanel',
    'debug_toolbar.panels.cache.CachePanel',
    'debug_toolbar.panels.signals.SignalsPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
    'debug_toolbar.panels.redirects.RedirectsPanel',
    'debug_toolbar.panels.profiling.ProfilingPanel',
    'template_timings_panel.panels.TemplateTimings.TemplateTimings',
]
yorffuoj commented 4 years ago

I have the same issue here. For information my configuration is: Python 3.7.9 Django 3.1.1 Debug Toolbar 3.1.1 Note that all other panels work fine, and this panel is the only third party I have

rocksongabriel commented 2 years ago

From the documentation, debug-toolbar-template-timings doesn't work with Django 2.0 and above.

x4base commented 1 year ago

Since django-debug-toolbar 2.0, the process_response method is deprecated. That's why the stats for template timings panel it not collected.

I can fix it by creating a new file called debug_toolbar_template_timings.py The content is as below:

from template_timings_panel.panels.TemplateTimings import TemplateTimings

class TemplateTimingsFixed(TemplateTimings):
    def process_request(self, request):
        response = super().process_request(request)
        self.process_response(request, response)
        return response

Finally, change you django settings, from 'template_timings_panel.panels.TemplateTimings.TemplateTimings', to 'debug_toolbar_template_timings.TemplateTimingsFixed',

It will work as expected.