class ProfileDetalView(DetailView):
model = User
template_name = 'blog/profile.html'
http://127.0.0.1:8000/profile/<slug:username>/
slug_url_kwarg = 'username'
- так как в запросе slug "кастомный", и его нужно явно указатьslug_field='username'
- так как в БД поле slug тоже называется usernameslug_field¶
The name of the field on the model that contains the slug. By default, slug_field is 'slug'.
slug_url_kwarg¶
The name of the URLConf keyword argument that contains the slug. By default, slug_url_kwarg is 'slug'.
urlpatterns = [ path("<slug:slug>/", ArticleDetailView.as_view(), name="article-detail"), ]