def get_permissions(self): # we need to use AllowAny() / IsAuthenticated() to instantiate an object # rather than using AllowAny / IsAuthenticated such class names if self.action == 'create': return [IsAuthenticated()] if self.action in ['destroy', 'update']: return [IsAuthenticated(), IsObjectOwner()] return [AllowAny()]
def get_permissions(self): # 注意要加用 AllowAny() / IsAuthenticated() 实例化出对象 # 而不是 AllowAny / IsAuthenticated 这样只是一个类名 if self.action == 'create': return [IsAuthenticated()] if self.action in ['destroy', 'update']: return [IsAuthenticated(), IsObjectOwner()] return [AllowAny()]
def get_permissions(self): # AllowAny() / IsAuthenticated() generate an object instance # not AllowAny / IsAuthenticated, this is just a class name if self.action == 'create': return [IsAuthenticated()] if self.action in ['destroy', 'update']: return [IsAuthenticated(), IsObjectOwner()] return [AllowAny()]
def get_permissions(self): # To instantiate an object, parens are needed # AllowAny() / IsAuthenticated() # not just class names like AllowAny / IsAuthenticated if self.action == 'create': return [IsAuthenticated()] if self.action in ['update', 'destroy']: return [IsAuthenticated(), IsObjectOwner()] return [AllowAny()]
def get_permissions(self): # 注意要加用 AllowAny() / IsAuthenticated() 实例化出对象 # 而不是 AllowAny / IsAuthenticated 这样只是一个类名 if self.action == 'create': return [IsAuthenticated()] if self.action in ['update', 'destroy']: # note: you need to verify you have login firstly return [IsAuthenticated(), IsObjectOwner()] return [AllowAny()]
def get_permissions(self): # return instance of AllowAny() or IsAuthenticated() if self.action == 'create': return [IsAuthenticated()] if self.action in [ 'destroy', 'update', ]: return [IsAuthenticated(), IsObjectOwner()] return [AllowAny()]
def get_permissions(self): if self.action == 'create': return [ IsAuthenticated(), ] elif self.action in ['update', 'destroy']: return [ IsAuthenticated(), IsObjectOwner(), ] elif self.action == 'list': return [ IsAuthenticated(), ] return [ AllowAny(), ]