How to make django unicode templates included?

I need help creating django templates with unicode. I am using Django 1.8 with python 2.7 on CENTOS 6.5. MySQL database is created using utf-8. When django displays some templates, I got the error:

UnicodeEncodeError at /
'ascii' codec can't encode character u'\xe9' in position 13: ordinal not in  range(128)
Request Method: GET
Request URL:    http://bluenanta.com:8000/
Django Version: 1.8.3
Exception Type: UnicodeEncodeError
Exception Value:    
'ascii' codec can't encode character u'\xe9' in position 13: ordinal not in range(128)
Exception Location: /home/bluenant/python/lib/python2.7/site-    packages/django/utils/encoding.py in force_text, line 94
Python Executable:  /home/bluenant/python/bin/python

      

=====================================

The following code example contains variables that can contain non-ascii strings (for example, image.species}} or {{image.foto}}

{% for image in random_list%}
   <li>{% if image.source_url %}
        <a href="{{image.source_url}}" target="_blank">{% endif %}
    <img src="{{ image.image_url }}" width="150"/>
    <br><font size=1px>{{image.id}} {{image.species}} {{image.variance}} 
    {%   if image.form %} forma {{image.form}}{% endif %}<br>
    {% if image.foto %} photo: {{image.foto}}{% endif %}
    {% if image.source_url %}</a>{% endif %}</font>
   </li>
{% endfor %}

      

+3
django unicode templates


source to share


No one has answered this question yet

Check out similar questions:

1643
Why templates can only be implemented in a header file?
1215
Why is Java code executed in comments with some Unicode characters?
212
Writing Unicode text to text file?
1
Python how to save dictionary with cyrillic characters to json file
1
How to send UNICODE message to smtplib in python
1
Creating h2o dataframe from pandas and unicode error
0
Python Unencode unicode html hex
0
Django template unicode exception
0
UnicodeEncodeError: codec 'ascii' cannot encode character u '\ xe9'
0
PyQt and Unicode error



All Articles
Loading...
X
Show
Funny
Dev
Pics