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

How to get the arclen between two curve points in Maya? -

C++ Linked List -

git svn - Unignore directories in git-svn (adding directories to a sparse checkout) -