【发布时间】:2021-05-10 11:23:47
【问题描述】:
????我迫切需要@classmethod
我正在使用此代码:
from rest_framework.response import Response
class MyClass():
@classmethod
@api_view(['GET', 'POST', 'PUT', 'DELETE'])
def CRUD(cls, request, id=0):
#.....
return Response({})
urlpatterns = [
re_path(r'^user/(?:(?P<id>[1-9]+)/)?$', UserView.CRUD)
]
得到错误:
The 'request' argument must be an instance of 'django.http.HttpRequest', not 'builtins.type'.
请帮忙;谢谢???????????????
【问题讨论】:
-
您在何时/何地收到该错误?请发布完整的回溯。
-
@api_view不适合基于类的视图 -
@deceze 对于所有请求,我有这个错误
-
@404pio 我该怎么办? ??????
标签: django django-rest-framework