У меня есть django проект с django-rest-framework с именем MyProject , в котором я создал приложение account .
У меня есть следующий код внутри MyProject / urls.py :
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('accounts.urls', namespace='accounts')),
path('admin/', admin.site.urls),
]
Внутри MyProject / accounts / urls.py , у меня есть:
from django.contrib import admin
from django.urls import path, include
from rest_framework import routers
from . import views
router = routers.DefaultRouter()
router.register('accounts', views.UserView)
urlpatterns = [
path('', router.urls)
]
Внутри MyProject / accounts / views.py :
import sys
from django.shortcuts import render, redirect
from django.contrib.auth.models import User, auth
from django.contrib import messages
from rest_framework import viewsets
from .serializers import UserSerializer
class UserView(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
Я получаю ошибку:
> File
> "C:\Users\user\PycharmProjects\MyProject\accounts\urls.py",
> line 10, in <module>
> path('', router.urls) File "C:\Users\user\PycharmProjects\MyProject\venv\lib\site-packages\django\urls\conf.py",
> line 61, in _path
> urlconf_module, app_name, namespace = view ValueError: too many values to unpack (expected 3)