recamshak / django-debug-panel

django-debug-toolbar in WebKit DevTools. Works fine with background Ajax requests and non-HTML responses.
BSD 3-Clause "New" or "Revised" License
404 stars 69 forks source link

Doesn't load under mod_wsgi #1

Closed ionelmc closed 11 years ago

ionelmc commented 11 years ago

It would appear that django will create the middleware class instances before loading the apps under the wsgi handler.

debug_panel should either document that you need to have import debug_panel in your settings or make a middleware subclass instead of the monkey-patching

This happens for me under django 1.4.

ionelmc commented 11 years ago

Traces:

This:

[Tue Oct 22 02:07:40 2013] [error]   File "/environment/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Tue Oct 22 02:07:40 2013] [error]     self.load_middleware()
[Tue Oct 22 02:07:40 2013] [error]   File "/environment/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
[Tue Oct 22 02:07:40 2013] [error]     mw_instance = mw_class()

gets run before this:

[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Tue Oct 22 02:07:41 2013] [error]     response = self.get_response(request)
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/core/handlers/base.py", line 89, in get_response
[Tue Oct 22 02:07:41 2013] [error]     response = middleware_method(request)
[Tue Oct 22 02:07:41 2013] [error]   File "/home/ionel/projects/django-debug-toolbar/debug_toolbar/middleware.py", line 85, in process_request
[Tue Oct 22 02:07:41 2013] [error]     urlconf = import_module(getattr(request, 'urlconf', settings.ROOT_URLCONF))
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Tue Oct 22 02:07:41 2013] [error]     __import__(name)
[Tue Oct 22 02:07:41 2013] [error]   File "proj/urls.py", line 4, in <module>
[Tue Oct 22 02:07:41 2013] [error]     admin.autodiscover()
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 29, in autodiscover
[Tue Oct 22 02:07:41 2013] [error]     import_module('%s.admin' % app)
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Tue Oct 22 02:07:41 2013] [error]     __import__(name)
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/contrib/auth/admin.py", line 171, in <module>
[Tue Oct 22 02:07:41 2013] [error]     admin.site.register(Group, GroupAdmin)
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 92, in register
[Tue Oct 22 02:07:41 2013] [error]     validate(admin_class, model)
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/contrib/admin/validation.py", line 22, in validate
[Tue Oct 22 02:07:41 2013] [error]     models.get_apps()
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/db/models/loading.py", line 126, in get_apps
[Tue Oct 22 02:07:41 2013] [error]     self._populate()
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/db/models/loading.py", line 64, in _populate
[Tue Oct 22 02:07:41 2013] [error]     self.load_app(app_name, True)
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/db/models/loading.py", line 86, in load_app
[Tue Oct 22 02:07:41 2013] [error]     app_module = import_module(app_name)
[Tue Oct 22 02:07:41 2013] [error]   File "/environment/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Tue Oct 22 02:07:41 2013] [error]     __import__(name)
recamshak commented 11 years ago

Thanks @ionelmc ! I will fix that ASAP, I don't even know why I monkey patched instead of subclassing in the first place.