Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Django link text too long

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{% for i in post.file_set.all %}<p class="article-content mt-2 mb-1"><strong>Privitak prijave {{ forloop.counter }}: </strong><a href="{{i.file.url}}">{{i.file.name}}</a></p>{% endfor %}

>Solution :

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

{{ i.file.name|truncatechars:20 }}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading