我的重音字符有問題。 Django管理員保存我的數據,而不編碼爲「á
」KeyError與Django,可交易的應用程序和重音字符?
例如:如果我試圖使用像「
我在我的地點:DEFAULT_CHARSET = 'utf-8'
我在我的mysql數據庫:utf8_general_ci
我使用社交場所應用:
{% load sociable_tags %}
{% get_sociable Facebook TwitThis Google MySpace del.icio.us YahooBuzz Live as sociable_links with url=object.get_absolute_url title=object.titulo %}
{% for link in sociable_links %}
<a href="{{ link.link }}"><img alt="{{ link.site }}" title="{{ link.site }}" src="{{ link.image }}" /></a>
{% endfor %}
但我發現瞭如果有錯誤我的object.titulo(文章標題)有一個重音詞。
Traceback:
File "C:\wamp\bin\Python26\lib\site-packages\django\core\handlers\base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "C:\wamp\bin\Python26\lib\site-packages\django\views\generic\date_based.py" in object_detail
366. response = HttpResponse(t.render(c), mimetype=mimetype)
File "C:\wamp\bin\Python26\lib\site-packages\django\template\__init__.py" in render
173. return self._render(context)
File "C:\wamp\bin\Python26\lib\site-packages\django\template\__init__.py" in _render
167. return self.nodelist.render(context)
File "C:\wamp\bin\Python26\lib\site-packages\django\template\__init__.py" in render
796. bits.append(self.render_node(node, context))
File "C:\wamp\bin\Python26\lib\site-packages\django\template\debug.py" in render_node
72. result = node.render(context)
File "C:\wamp\bin\Python26\lib\site-packages\django\template\loader_tags.py" in render
125. return compiled_parent._render(context)
File "C:\wamp\bin\Python26\lib\site-packages\django\template\__init__.py" in _render
167. return self.nodelist.render(context)
File "C:\wamp\bin\Python26\lib\site-packages\django\template\__init__.py" in render
796. bits.append(self.render_node(node, context))
File "C:\wamp\bin\Python26\lib\site-packages\django\template\debug.py" in render_node
72. result = node.render(context)
File "C:\wamp\bin\Python26\lib\site-packages\django\template\loader_tags.py" in render
62. result = block.nodelist.render(context)
File "C:\wamp\bin\Python26\lib\site-packages\django\template\__init__.py" in render
796. bits.append(self.render_node(node, context))
File "C:\wamp\bin\Python26\lib\site-packages\django\template\debug.py" in render_node
72. result = node.render(context)
File "C:\wamp\bin\Python26\lib\site-packages\sociable\templatetags\sociable_tags.py" in render
37. 'link': sociable.genlink(site, **self.values),
File "C:\wamp\bin\Python26\lib\site-packages\sociable\sociable.py" in genlink
20. values['title'] = quote_plus(kwargs['title'])
File "C:\wamp\bin\Python26\lib\urllib.py" in quote_plus
1228. s = quote(s, safe + ' ')
File "C:\wamp\bin\Python26\lib\urllib.py" in quote
1222. res = map(safe_map.__getitem__, s)
Exception Type: TemplateSyntaxError at /noticia/2010/jun/10/matan-domingo-paquete-en-la-avenida-san-vicente-de-paul/
Exception Value: Caught KeyError while rendering: u'\xfa'
謝謝!
需要整個回溯,所以我們可以看到問題出在哪裏。 – 2010-06-14 03:07:22
當然,但錯誤是與鹽水重音字 – Asinox 2010-06-14 19:45:33