我有一个基于工人阶级的观点。但是在添加@login_required 时出现错误:
AttributeError: 'function' 对象没有属性 'as_view'
这里的 ResultListView 发生了一些事情:
from django.urls import path
from .views import ResultListView
urlpatterns = [
path('meetings/', ResultListView.as_view(), name='meetings'),
]
Run Code Online (Sandbox Code Playgroud)
我的意见.py:
@login_required
class ResultListView(ListView):
template_name = ...
def get_queryset(self):
return Result.objects.filter(rider__user=self.request.user)
Run Code Online (Sandbox Code Playgroud)
在我将装饰器放入之前,一切正常。现在非常困惑,我不明白为什么ResultListView在通过装饰器发送时应该失去它的属性。