Role not working with DRF ViewSet
See original GitHub issueHello, I am trying to implement a DRF based application with some object level permissions.
I tired the following simple configuration with not success:
u = User.objects.get(username='user1')
assign_role(u, "test_role")
views.py
class MyObjectViewSet(HasRoleMixin, viewsets.ReadOnlyModelViewSet):
queryset = MyObject.objects.all()
serializer_class = MyObjectSerializer
allowed_roles = ['test_role']
roles.py
class TestRole(AbstractUserRole):
available_permissions = {
'list_my_objects': True,
}
I can successfully login in with user1
, but calling the get API over that view results in a 403 Forbidden error.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Django REST Framework viewset per-action permissions
Let's suppose I defined some permissions classes such as 'IsAdmin', 'IsRole1', 'IsRole2', ..., and I want to grant different permissions to the ...
Read more >Viewsets - Django REST framework
A ViewSet class is simply a type of class-based View, that does not provide any method handlers such as .get() or .post() ,...
Read more >Django REST Framework Views - ViewSets - TestDriven.io
The URL prefix for the views; The ViewSet itself. Then, we included the router inside urlpatterns . This is not the only way...
Read more >10 things you need to know to effectively use Django Rest ...
... I got to know while working with Django Rest Framework in Profile Software. ... Every time you write views that should do...
Read more >Viewsets and Routers with React Front-end Example - Part-4
Hello, we are back again for the forth tutorial in this Django Rest Framework Series. In the following series of tutorials we will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @filipeximenes , just tried replacing
viewsets.ReadOnlyModelViewSet
withgenerics.ListAPIView
but I get the same behaviorVery weird. Could you try using a
GenericView
instead of aViewSet
to see what happens?