Добрый день! Пытаюсь получить данные текущего пользователя для вывода на страницу. По ссылке, указанной мною
127.0.0.1:8000/cabinet/1, выдается ошибка. Почему?
models.py (crm)
from django.contrib.auth.models import AbstractUser
# Create your models here.
class CustomUser(AbstractUser):
pass
urls.py (третья строка в паттерне)
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.auth import login, logout
from crm.views import PersonalAccount, index, Registr
from orders.views import admin_order_detail
urlpatterns = [
path('admin/orders/order/<order_id>/change/', admin_order_detail, name='admin_order_detail'),
path('admin/', admin.site.urls),
path('cabinet/<pk>', PersonalAccount.as_view(), name='pers_account'),
path('registr/', Registr.as_view(), name='registr'),
path('accounts/', include("django.contrib.auth.urls")),
path('accounts/login/', login, name='login'),
path('accounts/logout/', logout, name='logout'),
path('product/', include('shop.urls', namespace='shop')),
path('orders/', include('orders.urls', namespace='orders')),
path('cart/', include('cart.urls', namespace='cart')),
path('coupons/', include('coupons.urls', namespace='coupon')),
path('', index, name='index'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
views.py (crm)
from django.views.generic import FormView
from django.views.generic import DetailView
from django.urls import reverse_lazy
from .forms import CustomUserCreationForm
from django.contrib.auth import login, authenticate
from django.shortcuts import render
from shop.models import Product
from crm.models import CustomUser
# Create your views here.
def index(request):
# slider_list = CmsSlider.objects.all()
products = Product.objects.all()
dict_obj = {'products': products}
return render(request, './index.html', dict_obj)
class PersonalAccount(DetailView):
model = CustomUser
template_name = 'pers_account.html'