Reputation: 63
Just a quick question.
How can I implement the "@" feature used on most social networks on my django project. for example, @ludipie(ludipie being a username) should link to ludipie's profile page when clicked.
Upvotes: 1
Views: 50
Reputation: 4677
You can set this in your templates
<a href="{{ request.user.profile.absolute_url }}">@{{request.user.username}}</a>
So basically you need to write absolute_url
method which will return url to user page.
An example of this method could be
def get_absolute_url(self):
return reverse('accounts:profile_detail', kwargs={'slug': self.slug})
Upvotes: 1