Django. 404. Создание профиля (личного кабинета) пользователя
При переходе по URL .../profile/1/ - выдаёт ошибку 404. Не понимаю что не так. Вот мой код:
urls.py
urlpatterns = [
path('', views.index),
path('main', views.index, name='main'),
path('registration', views.reg_user, name='reg'),
path('login', views.login_request, name='login'),
path('exit', authViews.LogoutView.as_view(next_page='main'), name='exit'),
path('profile/<int:pk>/', views.ShowProfilePageView.as_view(), name='user_profile'),
]
views.py
class ShowProfilePageView(DetailView):
model = Profile
template_name = 'my_profile/profile.html'
def get_context_data(self, *args, **kwargs):
users = Profile.objects.all()
context = super(ShowProfilePageView, self).get_context_data(*args, **kwargs)
page_user = get_object_or_404(Profile, id=self.kwargs['id'])
context['page_user'] = page_user
return context
*Примечательно, что "objects" и "args" в get_context_data - PyCharm подсвечивает как неверные
models.py
class Profile(models.Model):
user = models.OneToOneField(User, null=True, on_delete=models.CASCADE)
bio = models.TextField(null=True, blank=True)
profile_pic = models.ImageField(null=True, blank=True, upload_to='images/profile/')
skills = models.TextField(null=True, blank=True)
city = models.TextField(null=True, blank=True)
age = models.TextField(null=True, blank=True)
sex = models.TextField(null=True, blank=True)
def __str__(self):
return str(self.user)
profile.html
<html>
<head>
{% load static %}
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="{% static 'styles/my_profile/my_profile.css' %}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
</head>
<body>
<div class="header-bar">
<h1>Profile</h1>
</body>
</html>