2012-11-27 22 views
0

我使用夾層構建我的網站。在模板中,我使用templatetag。當我傳遞給像「categorytofilter」這templatetag字,它的確定,但是當我試圖通過unicode字符串:將unicode字符串傳遞給django模板中的templatetag導致錯誤

{% blog_recent_posts limit=6 category='Статьи' as recent_posts %} 

我看到的錯誤:

'ascii' codec can't encode characters in position 10-15: ordinal not in range(128) 

我怎樣才能解決呢? TIA!

+0

這有幫助嗎?我不確定具體是什麼答案,但我想這個鏈接會有所幫助:https://docs.djangoproject.com/en/dev/ref/unicode/#templates – themanatuf

+0

它並沒有幫助 – dizpers

回答

0

好像你是通過類ascii而不是unicode。

嘗試

{% blog_recent_posts limit=6 category=u'Статьи' as recent_posts %} 

,如果你硬編碼的類別,否則,請指定/傳遞到模板之前,在您看來投放。