django-simple-open-graph icon indicating copy to clipboard operation
django-simple-open-graph copied to clipboard

Direct unicode symbols in tag are not supported

Open coagulant opened this issue 10 years ago • 0 comments

{% opengraph_meta "url=/, title='Тут не поддерживается юникод', type='website'" %}
Request Method: GET
Request URL: http://project.coagulant/

Django Version: 1.4.9
Python Version: 2.7.5

Traceback:
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  136.                     response = response.render()
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/response.py" in render
  104.             self._set_content(self.rendered_content)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  79.         template = self.resolve_template(self.template_name)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/response.py" in resolve_template
  55.             return loader.select_template(template)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/loader.py" in select_template
  187.             return get_template(template_name)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/loader.py" in get_template
  145.     template, origin = find_template(template_name)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/loader.py" in find_template
  134.             source, display_name = loader(name, dirs)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/loader.py" in __call__
  42.         return self.load_template(template_name, template_dirs)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/loader.py" in load_template
  48.             template = get_template_from_string(source, origin, template_name)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/loader.py" in get_template_from_string
  156.     return Template(source, origin, name)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/base.py" in __init__
  125.         self.nodelist = compile_string(template_string, origin)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/base.py" in compile_string
  153.     return parser.parse()
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/base.py" in parse
  267.                     compiled_result = compile_func(self, token)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/loader_tags.py" in do_extends
  214.     nodelist = parser.parse()
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/base.py" in parse
  267.                     compiled_result = compile_func(self, token)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/loader_tags.py" in do_block
  189.     nodelist = parser.parse(('endblock',))
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/base.py" in parse
  267.                     compiled_result = compile_func(self, token)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/defaulttags.py" in do_with
  1350.     nodelist = parser.parse(('endwith',))
File "/home/coagulant/envs/project/lib/python2.7/site-packages/django/template/base.py" in parse
  267.                     compiled_result = compile_func(self, token)
File "/home/coagulant/envs/project/lib/python2.7/site-packages/simple_open_graph/templatetags/simple_open_graph.py" in opengraph_meta
  18.     properties = string_to_dict(properties[1:-1])
File "/home/coagulant/envs/project/lib/python2.7/site-packages/simple_open_graph/utils.py" in string_to_dict
  4.         string = str(string)

Exception Type: UnicodeEncodeError at /
Exception Value: 'ascii' codec can't encode characters in position 25-28: ordinal not in range(128)

Workaround is to use {% with %} tag:

{% with title='Тут не поддерживается юникод' %}
    {% opengraph_meta "url=/, title=title, type='website'" %}
{% endwith %}

coagulant avatar Feb 04 '14 07:02 coagulant