概述
class DocumentList(APIView): def get(self,request,format=None): ... blah def post(self,format=None): only allow administrators to create new documents ... blah
# settings.py REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated','rest_framework.permissions.DjangoModelPermissions' ) } # views.py class DocumentList(APIView): model = Document ...
DjangoModelPermissions权限映射can be found in the source.
> GET,OPTIONS和HEAD不需要许可,但由于我们指定了IsAuthenticated,我们仍然要求> POST地图添加> PUT和PATCH地图改变>删除要删除的地图
总结
以上是编程之家为你收集整理的如何在Django Rest Framework中为特定请求添加权限全部内容,希望文章能够帮你解决如何在Django Rest Framework中为特定请求添加权限所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧