django-commons / django-debug-toolbar

A configurable set of panels that display various debug information about the current request/response.
https://django-debug-toolbar.readthedocs.io
BSD 3-Clause "New" or "Revised" License
8.1k stars 1.05k forks source link

Django's cached templates break when coupled with Django Debug Toolbar #709

Closed monovertex closed 9 years ago

monovertex commented 9 years ago

I am using Django 1.8 and DDT 1.3 (both latest on PyPI). Given

TEMPLATE_LOADERS = (
    ('django.template.loaders.cached.Loader', (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
    ))
)

In my settings, I receive

Environment:

Request Method: GET
Request URL: [...]

Django Version: 1.8
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'easy_thumbnails',
 'rest_framework',
 'registration',
 'debug_toolbar',
 'crispy_forms',
 'silk',
 'ygo_core',
 'ygo_variables',
 'ygo_cards',
 'ygo_api')
Installed Middleware:
('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',
 'silk.middleware.SilkyMiddleware')

Traceback:
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  223.                 response = middleware_method(request, response)
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/debug_toolbar/middleware.py" in process_response
  129.             bits[-2] += toolbar.render_toolbar()
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/debug_toolbar/toolbar.py" in render_toolbar
  64.             return render_to_string('debug_toolbar/base.html', context)
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  98.             template = get_template(template_name, using=using)
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/template/loader.py" in get_template
  35.                 return engine.get_template(template_name, dirs)
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/template/backends/django.py" in get_template
  30.         return Template(self.engine.get_template(template_name, dirs))
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/template/engine.py" in get_template
  167.         template, origin = self.find_template(template_name, dirs)
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/template/engine.py" in find_template
  139.         for loader in self.template_loaders:
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/utils/functional.py" in __get__
  60.         res = instance.__dict__[self.name] = self.func(instance)
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/template/engine.py" in template_loaders
  94.         return self.get_template_loaders(self.loaders)
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/template/engine.py" in get_template_loaders
  99.             loader = self.find_template_loader(template_loader)
File "/root/webapps/ygorganizer/local/lib/python2.7/site-packages/django/template/engine.py" in find_template_loader
  122.             loader_instance = loader_class(*args)

Exception Type: TypeError at /collection/
Exception Value: __init__() takes exactly 3 arguments (2 given)

when trying to load any url.

monovertex commented 9 years ago

Nevermind, it seems it was something particular to my dev environment, after a reboot I can't reproduce this anymore.

darkpixel commented 9 years ago

I appear to be running into the same issue.

```ERROR 2015-06-05 08:52:34,782 base 15485 139680268945152 [u'TypeError: __init__() takes exactly 2 arguments (1 given)', 
u'  File "django/core/handlers/base.py", line 164, in get_response', 
u'  File "django/template/response.py", line 158, in render', 
u'  File "django/template/response.py", line 133, in rendered_content', 
u'  File "django/template/response.py", line 88, in _resolve_template', 
u'  File "django/template/response.py", line 78, in resolve_template', 
u'  File "django/template/loader.py", line 64, in select_template', 
u'  File "django/template/backends/django.py", line 30, in get_template', 
u'  File "django/template/engine.py", line 167, in get_template', 
u'  File "django/template/engine.py", line 139, in find_template', 
u'  File "django/utils/functional.py", line 60, in __get__', 
u'  File "django/template/engine.py", line 94, in template_loaders', 
u'  File "django/template/engine.py", line 99, in get_template_loaders', 
u'  File "django/template/engine.py", line 122, in find_template_loader', 
u'  File "django/template/loader.py", line 155, in __init__']

Downgrading from Django 1.8.2 to 1.7.8 magically fixes the problem.

tim-schilling commented 9 years ago

@darkpixel I can't reproduce this. Can you please provide some additional information about your setup that causes the errors?

darkpixel commented 9 years ago

I pip uninstalled django-debug-toolbar, and removed it from my INSTALLED_APPS and middleware, I'm still getting the same error.

After playing around for about an hour, I'm not sure what it is--but I'm convinced it's not django-debug-toolbar. It looks like django-debug-toolbar was unfortunate enough to be the first app to trigger the error.

I'll do more digging, but I think you're off the hook. ;)

Environment:

Request Method: GET
Request URL: http://127.0.0.1.xip.io:8000/

Django Version: 1.8.2
Python Version: 2.7.6
Installed Applications:
('django.contrib.contenttypes',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'raven.contrib.django.raven_compat',
 'stronghold',
 'django_filters',
 'ckeditor',
 'devserver',
 'instances',
 'gunicorn',
 'bootstrap3',
 'dbtemplates',
 'django_extensions',
 'holidayhope')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'stronghold.middleware.LoginRequiredMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'instances.middleware.MultiInstanceMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'devserver.middleware.DevServerMiddleware')

Traceback:
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  164.                 response = response.render()
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/response.py" in render
  158.             self.content = self.rendered_content
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  133.         template = self._resolve_template(self.template_name)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/response.py" in _resolve_template
  88.         new_template = self.resolve_template(template)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/response.py" in resolve_template
  78.             return loader.select_template(template, using=self.using)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/loader.py" in select_template
  64.                     return engine.get_template(template_name, dirs)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/backends/django.py" in get_template
  30.         return Template(self.engine.get_template(template_name, dirs))
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/engine.py" in get_template
  167.         template, origin = self.find_template(template_name, dirs)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/engine.py" in find_template
  139.         for loader in self.template_loaders:
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/utils/functional.py" in __get__
  60.         res = instance.__dict__[self.name] = self.func(instance)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/engine.py" in template_loaders
  94.         return self.get_template_loaders(self.loaders)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/engine.py" in get_template_loaders
  99.             loader = self.find_template_loader(template_loader)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/engine.py" in find_template_loader
  122.             loader_instance = loader_class(*args)
File "/home/aaron/.virtualenvs/toyandjoy/local/lib/python2.7/site-packages/django/template/loader.py" in __init__
  155.         super(BaseLoader, self).__init__(*args, **kwargs)

Exception Type: TypeError at /
Exception Value: __init__() takes exactly 2 arguments (1 given)
tim-schilling commented 9 years ago

Closing this, I'm guessing it wasn't the toolbar's problem.