djsutho / django-debug-toolbar-request-history

BSD 3-Clause "New" or "Revised" License
131 stars 23 forks source link

KeyError: None on stats for request_history #15

Closed PythonicNinja closed 6 years ago

PythonicNinja commented 7 years ago
Traceback (most recent call last):
  File "env/src/django/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "env/src/django/django/utils/deprecation.py", line 142, in __call__
    response = self.process_response(request, response)
  File "env/lib/python3.5/site-packages/debug_toolbar/middleware.py", line 102, in process_response
    new_response = panel.process_response(request, response)
  File "env/lib/python3.5/site-packages/ddt_request_history/panels/request_history.py", line 164, in process_response
    panel.generate_stats(request, response)
  File "env/lib/python3.5/site-packages/debug_toolbar/panels/profiling.py", line 170, in generate_stats
    root = FunctionCall(self.stats, self.stats.get_root_func(), depth=0)
  File "env/lib/python3.5/site-packages/debug_toolbar/panels/profiling.py", line 51, in __init__
    self.stats = statobj.stats[func][:4]
KeyError: None
djsutho commented 7 years ago

@PythonicNinja I can't replicate this are you able to give me some details on when this occurs e.g. on app start, on panel load? Also can I get the output from pip freeze?

djsutho commented 6 years ago

I'm looking to close this, @PythonicNinja do you have anything to add?

PythonicNinja commented 6 years ago

@djsutho sorry for delay from my side, I wasn't aware of your response year ago.

It was related to my settings.py which wasn't valid.

Long time ago but It seems that I still have good settings.py if anyone has same problem:

    INSTALLED_APPS += [
        'debug_toolbar',
    ]

    MIDDLEWARE = [
                     'debug_toolbar.middleware.DebugToolbarMiddleware',
                 ] + MIDDLEWARE

    DEBUG_TOOLBAR_PANELS = [
        'ddt_request_history.panels.request_history.RequestHistoryPanel',  # Here it is
        '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_CONFIG = {
        # only required for debug_toolbar versions below 1.8
        'SHOW_TOOLBAR_CALLBACK': 'ddt_request_history.panels.request_history.allow_ajax',
    }