Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Django have a template tag that can detect URLs and turn them into hyperlinks?

When someone writes a post and copies and pastes a url in it, can Django detect it and render it as a hyperlink rather than plain text?

like image 232
TIMEX Avatar asked Dec 16 '10 21:12

TIMEX


1 Answers

Django has the urlize template filter which will automatically detect both URLs and email addresses and turn them into the appropriate hyperlinks.

The docs there are actually a little thin, so I recommend also reading the docstring in the source for the urlize function for more information.

like image 148
Gabriel Hurley Avatar answered Nov 04 '22 21:11

Gabriel Hurley