12 questions
2 votes
1 answer
47 views
Do I need to serialize permissions in django rest framework
I'm using DRF and NextJS(app router) to build an application with a search feature that saves the authenticated user's search history. The search history is their search terms with a timestamp and ...
0 votes
1 answer
50 views
Why are permissions not being overridden for a viewset?
I have created a viewset for authentication. Since this is the authentication viewset, I want this viewset to be accessible to unauthorized users as well. Following DRF documentation, this is what I ...
1 vote
1 answer
55 views
django-rest-framework authentication and permission. Prevent authenticated user from posting if user is is_staff=false, is_superuser=false
I have a class based APIVIEW and I want to prevent a normal user (isstaff=false, is_superuser=false) from creating a customer. class CustomerPageView(APIView): # permission_required = 'api....
0 votes
2 answers
150 views
DRF post request test failing because a custom permission is stating that the "owner_id" field (custom field) does not match the authenticated user id
I'm starting to write tests for my endpoint, "categories/", and I can't get past a custom permission that I have added to the view that is being tested. In this permission, it checks the ...
1 vote
0 answers
209 views
Django REST Framework Viewset Executes Actions Multiple Times and Shows 'None' for GET Requests
I have a Django REST framework viewset with multiple actions such as list, create, and more. When I send a GET request, I noticed that some actions are executed multiple times, and the action is ...
0 votes
1 answer
1k views
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 ...
3 votes
1 answer
2k views
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 ...
0 votes
1 answer
51 views
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 ...
1 vote
2 answers
323 views
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. How can it also be made so that each author can see only his posts? from rest_framework import permissions class IsAuthorOrReadOnly(...
0 votes
1 answer
1k views
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 ...
51 votes
5 answers
30k views
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 ...
34 votes
5 answers
36k views
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 ...