Я получаю ошибку: "AttributeError: type object 'UserList' has no attribute 'as_view'", типа, он не видит "as_view()" [закрыто]

Получаю ошибку: "AttributeError: type object 'UserList' has no attribute 'as_view'", типа, он не видит "as_view()"

Мой urls.py в Userapp

from django.urls import path
from .views import *

urlpatterns = [
    path('list', UserList.as_view(), name = 'user-view')
]

views.py:

from django.shortcuts import render
from rest_framework.views import APIView
from django.contrib.auth.models import User
from .serializer import UserSerializer
from rest_framework import response

class UserList():
    def get(self, request, *args, **kwargs):
        user_list = User.objects.all()
        serializer = UserSerializer(instance = user_list, many = True)
        return response(data = serializer.data)

serializers.py:

from rest_framework.serializers import ModelSerializer
from django.contrib.auth.models import  User

class UserSerializer(ModelSerializer):
    class Meta:
        model = User
        fields = ['username', 'email', 'first_name',]
Вернуться на верх