Home > Net >  Django link text too long
Django link text too long

Time:10-24

In my detail view in my Django app I show links to all attached files in the Post. Problem is, if link is too long it goes beyond border. Is it possible to show only part of link if it's too long or to limit the 'preview', not to edit the link.

enter image description here

code:

{% for i in post.file_set.all %}<p ><strong>Privitak prijave {{ forloop.counter }}: </strong><a href="{{i.file.url}}">{{i.file.name}}</a></p>{% endfor %}

CodePudding user response:

You can use the |truncatechars template filter [Django-doc]:

{{ i.file.name|truncatechars:20 }}
  • Related