I want to turn every hashtag in the comment
textfield to url so that it will be clickable.
For example, a user submit,
s = "I can't get enough of #SO because #developers are very #supportive"
I want it to return like this in template,
I can't get enough of #SO because #developers are very #supportive
Where whole text will display and all hashtag will be clickable by embedding {hashtag}.
I tried the below templatetags code but it won't return the hashtags with the text. It will only return this,
<a href='http://example.com/tags/SO'>SO</a>
app_extras.py
import re
register = template.Library()
@register.filter(name='hashchange')
def hashchange(value):
vx=re.findall(r"#(\w+)", value)
for n in vx:
pm="<a href='http://example.com/tags/{0}'>{0}</a>".format(n)
return pm
In the template, I did,
{{object.comment|safe|hashchange}}
What am I missing?