David542
David542

Reputation: 110093

Template mark-up hyperlinks from plain text

Is there a template filter in django that does the following:

text = 'hello please visit this site: www.google.com.'

And turns it in the template to:

hello please visit this site: <a href="www.google.com">www.google.com</a>.

Upvotes: 0

Views: 90

Answers (1)

Raja Simon
Raja Simon

Reputation: 10305

Yes there is a template filter does this job

{{ text|urlize }}

If text variable is "hello please visit this site: www.google.com",

And the output will be

"hello please visit this site: <a href="www.google.com" rel="nofollow">www.google.com</a>".

Update : Click here for target="_blank"

Upvotes: 1

Related Questions