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

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -