Reputation: 877
I have
url(r'^profile/(?P<userid>\d+)', views.profile, name='profile'),
in the urls.py
And I have
def profile(request, userid):
What should I have for a button's href for guest visitors to be able to view the user profile page?
href="/accounts/profile/<userid>"
or
href="{% url 'users:profile' user.id %}"
I can't get neither of the above working. Thanks.
Upvotes: 0
Views: 263
Reputation: 372
I actually ran into this issue a few days ago.
{% url 'users:profile' user.id as profile_link %}
<a href="{{ profile_link }}">Profile</a>
Also for the future, your example did not include single quotes between the namespace and name of the url. You should have {% url 'users:namehere' %}
, not {% url users:namehere %}
Upvotes: 1