Questions tagged [django-rest-framework-permissions]

7 questions
49
votes
5 answers

What's the differences between has_object_permission and has_permission?

I am confused with the BasePermission in Django-rest-framework. Here I defined a class: IsAuthenticatedAndOwner. class IsAuthenticatedAndOwner(BasePermission): message = 'You must be the owner of this object.' def has_permission(self,…
33
votes
5 answers

Django REST framework object level permissions

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 they are an admin. If the user specifies their id, and they are logged in, I would…
3
votes
1 answer

Django Rest Framework Rate Limit Dynamic based on User Type

I'm building an API using Django Rest Framework (DRF) and I'm facing an issue with rate limiting. Specifically, I need to set different rate limits for different types of users: Staff members: 1000 requests per day Normal users: 100 requests per…
0
votes
1 answer

How to all only post method in a view set in Django REST_framework?

I have a Django REST_framework api and I have a UserViewSet class. For this view set I would like that anyone reaching the url can use the post method of the Viewset but cannot see all the users registered in the database. Here is my views.py #…
0
votes
1 answer

Is there a way to show only some model fields?

I have a model with field instances and have views. Can i make so that when you redirect to to main page you can see only ID, title, deadline, done? But when you redirect to the detail page you can see all the model fields. models.py: class…
0
votes
1 answer

How to restrict so that the author of the post can only see and edit his posts

In this code only the author of the post can edit his post, but how to also make so that the author of the post can see only his posts? from rest_framework import permissions class IsAuthorOrReadOnly(permissions.BasePermission): def…
0
votes
1 answer

Python Requests with Django Rest Framework - 'detail': 'Authentication credentials were not provided'

I've got a tiny function that just looks to get a response from my DRF API Endpoint. My DRF settings look like this: "DEFAULT_AUTHENTICATION_CLASSES": [ # Enabling this it will require Django Session (Including CSRF) …