djsutho / django-debug-toolbar-request-history

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

Error importing DebugToolbarMiddleware #14

Closed dirkmoors closed 6 years ago

dirkmoors commented 7 years ago

When I'm trying to integrate it into my project, I'm getting:

app_1       | Traceback (most recent call last):
app_1       |   File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
app_1       |     worker.init_process()
app_1       |   File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
app_1       |     self.load_wsgi()
app_1       |   File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
app_1       |     self.wsgi = self.app.wsgi()
app_1       |   File "/usr/local/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
app_1       |     self.callable = self.load()
app_1       |   File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
app_1       |     return self.load_wsgiapp()
app_1       |   File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
app_1       |     return util.import_app(self.app_uri)
app_1       |   File "/usr/local/lib/python3.5/site-packages/gunicorn/util.py", line 352, in import_app
app_1       |     __import__(module)
app_1       |   File "/data/src/ekona/wsgi.py", line 16, in <module>
app_1       |     application = get_wsgi_application()
app_1       |   File "/usr/local/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
app_1       |     return WSGIHandler()
app_1       |   File "/usr/local/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
app_1       |     self.load_middleware()
app_1       |   File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 80, in load_middleware
app_1       |     middleware = import_string(middleware_path)
app_1       |   File "/usr/local/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
app_1       |     module = import_module(module_path)
app_1       |   File "/usr/local/lib/python3.5/importlib/__init__.py", line 126, in import_module
app_1       |     return _bootstrap._gcd_import(name[level:], package, level)
app_1       |   File "/usr/local/lib/python3.5/site-packages/debug_toolbar/middleware.py", line 17, in <module>
app_1       |     from debug_toolbar.toolbar import DebugToolbar
app_1       |   File "/usr/local/lib/python3.5/site-packages/debug_toolbar/toolbar.py", line 135, in <module>
app_1       |     urlpatterns = DebugToolbar.get_urls()
app_1       |   File "/usr/local/lib/python3.5/site-packages/debug_toolbar/toolbar.py", line 128, in get_urls
app_1       |     for panel_class in cls.get_panel_classes():
app_1       |   File "/usr/local/lib/python3.5/site-packages/debug_toolbar/toolbar.py", line 111, in get_panel_classes
app_1       |     for panel_path in dt_settings.get_panels()
app_1       |   File "/usr/local/lib/python3.5/site-packages/debug_toolbar/toolbar.py", line 111, in <listcomp>
app_1       |     for panel_path in dt_settings.get_panels()
app_1       |   File "/usr/local/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
app_1       |     module = import_module(module_path)
app_1       |   File "/usr/local/lib/python3.5/importlib/__init__.py", line 126, in import_module
app_1       |     return _bootstrap._gcd_import(name[level:], package, level)
app_1       |   File "/usr/local/lib/python3.5/site-packages/ddt_request_history/panels/request_history.py", line 19, in <module>
app_1       |     from debug_toolbar.middleware import DebugToolbarMiddleware

I'm on Django 1.10.7, Debug Toolbar 1.8, and master branch for this repo.

djsutho commented 7 years ago

@dirkmoors can I get the result from pip freeze? Hopefully I can look into this on the weekend.

djsutho commented 7 years ago

@dirkmoors Can I get some information about how you are running this? It looks like you are using gunicorn and not the django dev server. Can you confirm that this works with the django debug toolbar without the requests panel (I'm not sure if if the toolbar was designed to run outside of the dev server)?

dirkmoors commented 7 years ago

Hi,

The output of pip freeze:

amqp==2.2.1
apipkg==1.4
Babel==2.4.0
behave==1.2.5
billiard==3.5.0.3
boto3==1.4.4
botocore==1.5.82
celery==4.0.2
certifi==2017.4.17
chardet==3.0.4
cloudinary==1.8.0
coreapi==2.3.1
coreschema==0.0.4
coverage==4.4.1
coverage2clover==1.2.0
Cython==0.25.2
Django==1.10.7
django-braces==1.11.0
django-celery-results==1.0.1
django-cloudinary-storage==0.2.1
django-countries==4.6.1
django-crispy-forms==1.6.1
django-debug-toolbar==1.8
django-debug-toolbar-request-history==0.0.4
django-environ==0.4.3
django-extensions==1.8.1
django-filter==1.0.4
django-fsm==2.6.0
django-fsm-admin==1.2.4
django-guardian==1.4.9
django-oauth-toolkit==0.12.0
django-phonenumber-field==1.3.0
django-redis==4.8.0
django-rest-swagger==2.1.2
django-storages==1.6.3
django-taggit==0.22.1
django-taggit-serializer==0.1.5
djangorestframework==3.6.3
djoser==0.6.0
docutils==0.13.1
drf-extensions==0.3.1
drf-tus==1.17
execnet==1.4.1
factory-boy==2.6.1
fake-factory==0.7.2
flake8==3.1.0.dev0
flower==0.9.2
future==0.16.0
graphviz==0.8
gunicorn==19.7.1
idna==2.5
itypes==1.1.0
Jinja2==2.9.6
jmespath==0.9.3
jsonfield==2.0.2
kombu==4.0.2
MarkupSafe==1.0
mccabe==0.5.3
mock==2.0.0
newrelic==2.88.1.73
oauthlib==2.0.1
olefile==0.44
openapi-codec==1.3.2
parse==1.8.2
parse-type==0.3.4
pbr==3.1.1
phonenumberslite==8.6.0
Pillow==4.2.1
psycopg2==2.7.1
py==1.4.34
pycodestyle==2.0.0
pyflakes==1.3.0
Pygments==2.2.0
pytest==3.1.3
pytest-cov==2.5.1
pytest-django==3.1.2
pytest-xdist==1.18.1
python-dateutil==2.6.1
python-dockercloud==1.0.12
python-magic==0.4.13
pytz==2017.2
PyYAML==3.12
redis==2.10.5
requests==2.18.1
s3transfer==0.1.10
simplejson==3.11.1
six==1.10.0
sqlparse==0.2.3
tblib==1.3.2
tornado==4.5.1
uritemplate==3.0.0
urllib3==1.21.1
vine==1.1.4
watchtower==0.3.6
websocket-client==0.44.0

Without adding the "request history" panel, everything runs fine, also with gunicorn. It even works fine in a production setup.

In the production setup, I work with docker (docker-cloud) in which I serve the gunicorn processes. On top of that, there is a HAProxy layer, and an Amazon ELB layer.

djsutho commented 7 years ago

I think I've fixed this but it's a bit hacky so could you test out the new version and report back?

dirkmoors commented 7 years ago

@djsutho Thanks! What branch / commit contains the fix?

djsutho commented 7 years ago

pip install -U django-debug-toolbar-request-history Should work.

Looks like I forgot to push the changes here so will do that when I get a chance.

djsutho commented 7 years ago

I've pushed this up. This is the fix https://github.com/djsutho/django-debug-toolbar-request-history/commit/6baf17cfa62708f5514674a4d87893f4944e0fb2

djsutho commented 6 years ago

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