Skip to content

cycle tag in templates cause INTERNAL SERVER ERROR in django 1.6 #546

Closed
naimetti opened this Issue Feb 12, 2014 · 5 comments

4 participants

@naimetti

cycle tag in templates cause INTERNAL SERVER ERROR in django 1.6

It could be fixed by simple add {% load cycle from future %} in these templates:

templates/debug_toolbar/panels/request.html
templates/debug_toolbar/panels/sql_explain.html
templates/debug_toolbar/panels/cache.html
templates/debug_toolbar/panels/versions.html
templates/debug_toolbar/panels/timer.html
templates/debug_toolbar/panels/settings.html
templates/debug_toolbar/panels/signals.html
templates/debug_toolbar/panels/headers.html
templates/debug_toolbar/panels/sql.html
templates/debug_toolbar/panels/staticfiles.html
templates/debug_toolbar/panels/sql_profile.html
templates/debug_toolbar/panels/sql_select.html
templates/debug_toolbar/panels/logging.html

Details:

PendingDeprecationWarning at /debug/render_panel/
'The cycle template tag is changing to escape its arguments; the non-autoescaping version is deprecated. Load it from the future tag library to start using the new behavior.

File "/usr/lib64/python3.3/site-packages/django/core/handlers/base.py" in get_response

  1. response = wrapped_callback(request, callback_args, *callback_kwargs) File "/usr/lib64/python3.3/site-packages/debug_toolbar/views.py" in render_panel
  2. content = panel.content File "/usr/lib64/python3.3/site-packages/debug_toolbar/panels/init.py" in content
  3. return render_to_string(self.template, self.get_stats()) File "/usr/lib64/python3.3/site-packages/django/template/loader.py" in render_to_string
  4. t = get_template(template_name) File "/usr/lib64/python3.3/site-packages/django/template/loader.py" in get_template
  5. template, origin = find_template(template_name) File "/usr/lib64/python3.3/site-packages/django/template/loader.py" in find_template
  6. source, display_name = loader(name, dirs) File "/usr/lib64/python3.3/site-packages/django/template/loader.py" in call
  7. return self.load_template(template_name, template_dirs) File "/usr/lib64/python3.3/site-packages/django/template/loader.py" in load_template
  8. template = get_template_from_string(source, origin, template_name) File "/usr/lib64/python3.3/site-packages/django/template/loader.py" in get_template_from_string
  9. return Template(source, origin, name) File "/usr/lib64/python3.3/site-packages/debug_toolbar/panels/templates/panel.py" in new_template_init
  10. old_template_init(self, template_string, origin, name) File "/usr/lib64/python3.3/site-packages/django/template/base.py" in init
  11. self.nodelist = compile_string(template_string, origin) File "/usr/lib64/python3.3/site-packages/django/template/base.py" in compile_string
  12. return parser.parse() File "/usr/lib64/python3.3/site-packages/django/template/base.py" in parse
  13. compiled_result = compile_func(self, token) File "/usr/lib64/python3.3/site-packages/django/template/defaulttags.py" in do_for
  14. nodelist_loop = parser.parse(('empty', 'endfor',)) File "/usr/lib64/python3.3/site-packages/django/template/base.py" in parse
  15. compiled_result = compile_func(self, token) File "/usr/lib64/python3.3/site-packages/django/template/defaulttags.py" in cycle
  16. PendingDeprecationWarning, stacklevel=2)
@aaugustin

Unless you're running under -Werror, this should just be a warning, not an error.

{% load cycle from future %} would break Django 1.4 and 1.5, while the Debug Toolbar aims at supporting all current versions of Django. Simply adding it isn't an acceptable solution.

@aaugustin aaugustin added the Bug label Feb 13, 2014
@tim-schilling

Would it be reasonable to check the version of Django and load from future if it's >= 1.6?

@aaugustin

That wouldn't suffice, we'd also need a different syntax wherever the tag is used in templates.

The only solution I can think of at this time is copying the definition of the new cycle tag in the toolbar.

@aaugustin

Closing as the reporter never answered my question about -Werror.

@aaugustin aaugustin closed this Apr 3, 2014
@blopker
blopker commented Aug 16, 2014

If anyone coming here has this problem and can't disable -Werror (for what ever reason) put this in your settings.py:

import warnings
warnings.filterwarnings('ignore', category=PendingDeprecationWarning)

This disables all PendingDeprecationWarning warnings, so be careful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.