Questions tagged [django-permissions]

django-permissions is a pluggable django app that provides per-object permissions for Django based on roles

django-permissions is a pluggable django app that provides per-object permissions for Django based on roles.

431 questions
0
votes
4 answers

How to apply permissions on perform_create in ViewSet DRF

This is my View Set: class MyViewSet(ModelViewSet): serializer_class = MySerializer queryset = MyClass.objects.all() def get_serializer_class(self): if self.request.user.is_superuser: return self.serializer_class …
0
votes
0 answers

Django share common permission across django app

I would like to know if there is a better way to implement common permission that is very similar across django app. For example, app1 need permission_x, app2 need permission_x, and app3 need permission_x too. In order to satisfy this i made…
whoami
  • 141
  • 1
  • 9
0
votes
0 answers

Is it necessary add IsAuthenticated permissions to permission_classes in view that is inherited from LoginRequiredMixin

I have a class-based view called ProfileDetail. It is inherit LoginRequiredMixin from django.contrib.auth.mixins. And then set permission_classes = (IsAuthenticated,). Basically all client that view ProfileDetail is already logged-in, hence…
0
votes
0 answers

Why all permissions checks?

I am new in django and drf in my project I have two group of permissions 1.normal_user group : with view_issue,view_project,view_analyzeissue 2.manager_user : with all permission as possible i have some views that check some permissions for example…
0
votes
0 answers

How to get list of users by passing permissions and roles string in Django

I searched many links over here. I don't know how to write the above functionality using Django. I wanted to list all the user by permissions or roles in Django. Read many blogs and we have option to get the list of permission or roles assigned to…
0
votes
0 answers

how to delete an object in modelViewset in DRF?

I am doing a project in DRF and using modelviewset, my object has two boolean fields and two users as foreign keys, now i want to show the object only to those users and if both of them set their correspond's boolean attribute to True then the…
0
votes
0 answers

How to set permissions for HR and TL for request approval in django rest framework

I'm working on HRMS application in django rest framework I want to set permissions for Hr and Team leader to approve leave request of employees. How can i achieve. If it's admin approval i can easily do that. But since it's hr and tl i should…
0
votes
1 answer

How do I use permission_classes in a custom method of a Viewset in DjangoRestFramework?

Suppose that I have a Viewset named UserViewset, and I have assigned IsAuthenticated permission to UserViewset Viewset. Now, I want to create a normal method (not an action method), and I want to assign another permission to that method which is…
0
votes
0 answers

Forbidden (CSRF cookie not set.): /auth for obtaining_auth_token

I am trying to get an auth token for the client (OrderClient.py). This keeps failing with Forbidden (CSRF cookie not set.): /auth. Here is my views from rest_framework.decorators import api_view,permission_classes,authentication_classes from…
0
votes
1 answer

Django custom permission not being assigned to newly created User

This seems pretty trivial but I can't figure out what I'm doing wrong. I've checked several SO posts that sounded similar but the issue apparently lies elsewhere. I have a custom permission on my model, can_key, and this is registered properly. When…
ron_g
  • 1,474
  • 2
  • 21
  • 39
0
votes
2 answers

Handle Django Rest Framework permission when creating related objects

The has_object_permission method of a Permission on DRF obviously does not get executed on Create, since the object does not exist yet. However, there are use cases where the permission depends on a related object. For example: class…
0
votes
0 answers

How to use permissions added using django-rules library in Django App?

I am creating a Django App in which I am using django-rules library to define and add permissions. I have followed the documentation and created the predicates in a separate file called permissions.py. I have also added the permissions in the same…
0
votes
1 answer

Why Django auto adds permissions to group?

Currently I'm making some groups for my backend and I noticed through the admin panel that the groups have some extra permissions I did not add. What is the cause of this behavior? models.py: produccion_group, created =…
0
votes
1 answer

Implement Django permissions per group per user's companies

I have a CustomUser model, each user could be linked to multiple companies. I have initiated my application with 3 generic Django groups; viewer, editor, and supervisor and each user could be a member in only one group. class…
0
votes
1 answer

Pass arguement to custom permision class in django

I have a custom permission class that extends the rest framework base permission. I am trying to pass an argument allowed_groups that will be a list of all the groups that have access to the particular view. This is my current custom permission…