Closed
Description
This is a bit of a strange one. I have both django-debug-toolbar and django-rosetta installed. Once I go to the http://localhost:8000/rosetta/ url and pick a language for translation, I get this error. Once this error has come out, it won't be able to render any other pages without error. I am running this with postgresql and manage.py runserver:
Traceback (most recent call last):
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 279, in run
self.result = application(self.environ, self.start_response)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 651, in __call__
return self.application(environ, start_response)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 245, in __call__
response = middleware_method(request, response)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/debug_toolbar/middleware.py", line 91, in process_response
response.content = replace_insensitive(smart_unicode(response.content), u'</body>', smart_unicode(self.debug_toolbars[request].render_toolbar() + u'</body>'))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/debug_toolbar/toolbar/loader.py", line 72, in render_toolbar
'BASE_URL': self.request.META.get('SCRIPT_NAME', ''),
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/loader.py", line 108, in render_to_string
return t.render(context_instance)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/test/utils.py", line 29, in instrumented_test_render
return self.nodelist.render(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/debug.py", line 71, in render_node
result = node.render(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/defaulttags.py", line 155, in render
nodelist.append(node.render(context))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/defaulttags.py", line 243, in render
return self.nodelist_true.render(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/debug.py", line 71, in render_node
result = node.render(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/debug.py", line 87, in render
output = force_unicode(self.filter_expression.resolve(context))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/__init__.py", line 546, in resolve
obj = self.var.resolve(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/__init__.py", line 687, in resolve
value = self._resolve_lookup(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/__init__.py", line 722, in _resolve_lookup
current = current()
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/debug_toolbar/panels/request_vars.py", line 32, in content
return render_to_string('debug_toolbar/panels/request_vars.html', context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/loader.py", line 108, in render_to_string
return t.render(context_instance)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/test/utils.py", line 29, in instrumented_test_render
return self.nodelist.render(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/debug.py", line 71, in render_node
result = node.render(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/defaulttags.py", line 243, in render
return self.nodelist_true.render(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/debug.py", line 81, in render_node
raise wrapped
TemplateSyntaxError: Caught an exception while rendering: ('ascii', u'# SOME DESCRIPTIVE TITLE.\n# Copyright (C) 2010\n# This file is distributed under the same license as the package.\n#
... snip ...
Original Traceback (most recent call last):
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/debug.py", line 71, in render_node
result = node.render(context)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/defaulttags.py", line 155, in render
nodelist.append(node.render(context))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/debug.py", line 87, in render
output = force_unicode(self.filter_expression.resolve(context))
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/__init__.py", line 572, in resolve
new_obj = func(obj, *arg_vals)
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/template/defaultfilters.py", line 37, in _dec
args[0] = force_unicode(args[0])
File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/utils/encoding.py", line 74, in force_unicode
s = unicode(str(s), encoding, errors)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 832-835: ordinal not in range(128)
The trace shows django-debug-toolbar in the trace so I am opening the issue here. Disabling the debug-toolbar code makes it work again.
Please let me know if you need more information than this to figure it out. Also, I don't really understand how the debug toolbar works with other plugins so if you think this is actually a bug in the other middleware, let me know and I will open it there.