python - Django slice string in template doesn't work -


i'm trying slice string doesn't work. works on other variables 1 nothing.

{{b.rec_company|slice:":2"}} 

you use slice pre-django 1.4:

{{b.rec_company|slice:'2'}}  {{ b.rec_company|slice:":-3" }} 

if using django 1.4 or greater,

you can use truncatechars

{{b.rec_company|truncatechars:2}} 

for more reference use slice-string-in-template


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -