Can I cut out the string in the Django template?

Viewed 10961

This is my code in templates:

{% for wine_con in data.winry_consult %}
    <li><a href="/article_list_content-{{win_con.id}}/"><p>{{ win_con.content }}</p><i class="font">&#xe6aa;</i></a></li>
{% endfor %}

I found the win_con.content is too long for my website, I only want 5 count characters, how can I cut out the win_con.content in template?

4 Answers

To cut specific characters do you could use 'cut' which is also part of django template builtins

for example if

{{ file.pdf.name}}

gives 'store/pdfs/verma2010.pdf'

{{ file.pdf.name | cut:'store/pdfs/'}}

Would give 'verma2010.pdf'

Related