Zorgan
Zorgan

Reputation: 9123

Truncate links/<a> tags in Django?

I'm utilising Django's template tag urlize, which automatically converts URLs in a string to a clickable link. E.g:

<p>{{ i.comment_text|urlize }}</p> 

I want to truncate those links. Is this possible using Django syntax?

Upvotes: 1

Views: 446

Answers (1)

MatrixTXT
MatrixTXT

Reputation: 2502

I think you are taking about urlizetrunc

<p>{{ i.comment_text|urlizetrunc:10 }}</p> 

It will truncate your link to certain word length.

However, if you want to change the whole word/ pattern, then no. You cannot do this though django only.

Upvotes: 2

Related Questions