Django REST framework object level permissions

前端 未结 5 1953
我寻月下人不归
我寻月下人不归 2021-02-01 03:46

I am using Django REST Framework to access a resource \'user\'.

As user information is personal, I do not want a GET request to list every user on the system, UNLESS the

5条回答
  •  走了就别回头了
    2021-02-01 04:20

    For the stumble-upons, the documentation under limitations of object level permission says:

    For performance reasons the generic views will not automatically apply object level permissions to each instance in a queryset when returning a list of objects.
    

    So, details view will work but for the list, you'll need to filter against the current user.

提交回复
热议问题