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
4
votes
2 answers

Django 2.1 View Permission

The Django Doc states that the new View Permission is added to Django 2.1 but without further clarifications on how this will be used especially on the Django Admin Site. It is my understanding this will be kind of ReadOnly Permission, but I will…
Paullo
  • 2,038
  • 4
  • 25
  • 50
4
votes
1 answer

Why I can't assign new permission to group in the same migration in Django

I'm trying to add new migrations by following this tutorial I added new permission inside Meta into permissions field. Then I created migration and tryed to modify this migration to update group permissions in place. But got DoesNotExist in…
Danil
  • 4,781
  • 1
  • 35
  • 50
4
votes
1 answer

Django Hierarchy Permissions

I want to have hierarchical level permissions in my Django Applications. For example:- Consider there are 4 levels - Admin Sub-admin(CountryLevel(CL) Admin) sub-sub-admin(StateLevel(SL) Admin) And then normal Users(U). Admins will create CL, in…
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267
4
votes
1 answer

Django Python : adding custom permissions to specific users

Models.py class Meta: permissions = ( ("can_add_data","can add a new data"), ) This is the custom permission I've created in Models.py and I've also created these users. Users in Django Admin ie., http://localhost:8000/admin…
Vinay Guda
  • 55
  • 1
  • 1
  • 9
4
votes
3 answers

Creating custom permission in data migration

I was trying to create a custom permission in a migration, however after running migrate, the permission was not created in the permission table. Could someone point out what the error was? Also I am not sure what I should use as the related model…
Aithusa
  • 169
  • 1
  • 14
4
votes
2 answers

django access control based on a model field value

I have a model class Department with a field name. I have another Model Student with a foreign key to Department. I want to control access to Student objects based on department. That is, a user with permission to edit the department with name "CS"…
Rohith
  • 1,301
  • 3
  • 21
  • 31
4
votes
1 answer

When adding permissions to User - ValueError: too many values to unpack

I created a custom user and add permission is_driver to check whether my user belongs to Driver's Group. class CustomUser(AbstractUser): mobile = models.CharField(max_length=16) address = models.CharField(max_length=100) class Meta: …
Andrew
  • 423
  • 1
  • 6
  • 16
4
votes
3 answers

How to set multiple permissions in one class view, depending on http request

I am working with django-rest-framework. The problem I am having is that the url is identical for both the POST and the GET methods but I want to have different permissions depending on which method is being called. Right now I'm using class based…
4
votes
1 answer

Setting Permissions to a group/User in Django

I've a group in auth_group table. I need to set permissions to a group. There are set of permissions in auth_permission table. Now If I need to map all the permissions to a group, do I need to add different rows for each permissions, or can it be…
user2935897
  • 117
  • 7
4
votes
1 answer

Customize user's admin panel permission only to read(not delete,edit or add)

I want a end-user to use admin-panel to see the obejcts created, but i dont want him to add-delete or edit any object created. But in django admin panel user settings, only permissions are add, delete or edit. Is there a way to do this ?
tuna
  • 6,211
  • 11
  • 43
  • 63
4
votes
1 answer

How do I define default permissions for users in Django Guardian?

When I create a user in Django, he has no permissions: In [7]: u = User.objects.create(username='aoeu') In [12]: u.user_permissions.all() Out[12]: [] I want some permissions to be set by default (say, 'api.add_item'), and I use Django Guardian. Is…
culebrón
  • 34,265
  • 20
  • 72
  • 110
4
votes
2 answers

django-guardian example source code

Can anyone suggest a good open source app that uses django-guardian? I'm not having trouble understanding the API, but I'd love to see an example to get a feel for implementation best practice (database design, etc.)
3
votes
2 answers

How to show permissions to add or change a Django model in Group or user permission list on Admin site?

I am able to run a Django Admin site and when I login as the SuperUser I'm able to modify my model as well. This part works perfectly. When I login as a user that is NOT a super user, the user does not see an option to modify this Model. When I…
Sid
  • 7,511
  • 2
  • 28
  • 41
3
votes
0 answers

Object level permission at ORM level in Django

I have a Django application (mainly a rest API) with a completely custom User model (not inhered from Django). My authentication is based on JWT tokens. I would like to make sure a user cannot access to data of another user. I have checked the…
poiuytrez
  • 21,330
  • 35
  • 113
  • 172
3
votes
1 answer

Make PermissionRequiredMixin also check for object level permission

I am using Django Guardian to have object-level permission along with global permissions. Some of the users have a group with global permissions, and some have object-level permissions. With this, I seem to need to modify the PermissionRequiredMixin…
kaiser
  • 115
  • 10