I have `content` = 'Please get me the Python book you talked about, @friend'

Then this in my **views.py**:

`new_content = re.sub(r'(@\w+)', r"<a href='#'>\g<0></a>>", content)`

This returns 

```
new_content = 'Please get me the Python book you talked about, <a href='#'>@friend</a>'

```

I want if a user clicks of `@friend`, it should redirect to this **url**:

```
url(r'^user/(?P<user_name>\w+)/$', views.profile, name='profile'),

```

How do I include this url(`profile`) in `<a href='#'></a>` in my **views.py** as I would have done in Django template like this `<a href="{% url 'mysite:profile' user.username %}">@{{user.username}}</a>`?