我最近开始使用DRF,并注意到它要求我们使用类级别变量(如下面的authentication_classes
)来设置身份验证,权限,呈现等。
class ListUsers(APIView):
authentication_classes = (authentication.TokenAuthentication,)
def get(self, request):
pass
我的第一个问题是这些变量叫什么?是"班级"正确的用语?其次,这些如何运作?这种用法对我来说很奇怪 - 声明"特殊"变量,但不是自己在课堂上使用它们'随后的陈述。