python - Can I cut out the string in the Django template? -


this code in templates:

{% 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 win_con.content long website, want 5 count characters, how can cut out win_con.content in template?

you can use slice filter:

<li><a href="/article_list_content-{{win_con.id}}/"><p>{{ win_con.content|slice:":5" }}</p><i class="font">&#xe6aa;</i></a></li> 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -