I'm new to Django 2.0 and i'm getting this error when visiting my profile page view. It's working with urls like path('users/<int:id>')
but i wanted to urls be like path('<username>')
. Not sure what exactly is the problem. I hope you can help.
#views.py
class ProfileView(views.LoginRequiredMixin, generic.DetailView):
model = models.User
template_name = 'accounts/profile.html'
#urls.py
urlpatterns = [
path('', HomePageView.as_view(), name='home'),
path('signup', SignUpView.as_view(), name='signup'),
path('login', LoginView.as_view(), name='login'),
path('logout', logout_view, name='logout'),
path('<username>', ProfileView.as_view(), name='profile')
]
#base.html
<ul class="dropdown-menu">
<li><a href="{% url 'accounts:profile' user.username %}">View Profile</a></li>
<li><a href="#">Edit Profile</a></li>
</ul>
username
? Does{% url 'accounts:profile' "bob" %}
work? – Chaney