In Django template, there is a very nice feature, we can use unicode character variable in template, for example:
{% for article in 文章列表 %} <li><a href="/articles/{{ article.id }}">{{ article.title }} </a></li> {% endfor %} In this way, if you didn't define 文章列表 in context, it'll raise an exception: Caught an exception while rendering: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128). but if we use an ascii based variable without pre-define, there isn't an exception. So I just add two lines to resolve this question, in django/template/ __init__.py", line 734-735, I used django 1.0 730 except Exception, e: 731 if getattr(e, 'silent_variable_failure', False): 732 current = settings.TEMPLATE_STRING_IF_INVALID 733 # Add by Timesong 2009/08/12 734 elif not isinstance(bit, str): 735 current = settings.TEMPLATE_STRING_IF_INVALID 736 # End add 737 else: 738 raise Hope this is useful. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---