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

Create django groups programmatically

I want to create groups in django programmatically, but not in a view, but rather in something like model (for example using migrations). How to do it? There's no information about it in google and docs (at least not here:…
b174662
  • 111
  • 1
  • 6
10
votes
1 answer

can't change user permissions during unittest in django

I've finally decided to make some tests for my apps but I'm stuck on testing if a user can change another user (depends on the type of the user -- I use django-rules to be able to do logical permission checks, but this is not important) Here's the…
Clash
  • 4,896
  • 11
  • 47
  • 67
9
votes
1 answer

django - comparing django permissions and using django rules

currently I am looking implementing access control in Django. I've read about the built-in permission, but it does not takes care per object basis. For example, I want permissions like "Only the creator can delete his own items". So I read about…
goh
  • 27,631
  • 28
  • 89
  • 151
9
votes
2 answers

How to implement Django multiple user types, while one user can have different role according to the project he/she is working on?

I couldn't find a solution to my problem and would appreciate comments/help on this. I would like to develop a multiple user type model in Django, along the lines of this video where the author is using Django Proxy Models. Situation I have a list…
lhoupert
  • 584
  • 8
  • 25
8
votes
3 answers

Django - Showing different templates to admins

In Django what's the best way to implement templates with extra functionality for users with 'admin' permissions. I'm not sure if I should create a set of completely different views specific for admins or integrate it into my existing views and…
9-bits
  • 10,395
  • 21
  • 61
  • 83
8
votes
2 answers

Django admin - change permissions list

Is there any possibility to change permissions list in user edit page? I don't wan't to show all of permissions for example admin log entry or auth group etc. How can I modify a main queryset to exclude some of it?
robos85
  • 2,484
  • 5
  • 32
  • 36
7
votes
3 answers

Django permissions

I would love to have more granular permission in my Django project, but can't decide what app to use. What I have is something like: class Item(models.Model): name = models.CharField(max_length=64, unique=True) description =…
rthill
  • 143
  • 3
  • 11
7
votes
2 answers

DRF Viewset remove permission for detail route

I have a basic Viewset: class UsersViewSet(viewsets.ModelViewSet): permission_classes = (OnlyStaff,) queryset = User.objects.all() serializer_class = UserSerializer It is bind to the /api/users/ endpoint. I want to create a user profile…
yierstem
  • 1,933
  • 5
  • 21
  • 42
7
votes
1 answer

You do not have permission to perform this action when accessing api in django

i am trying to add custom permissions in my Django app using Django rest framework. i created an API n tested it in postman it works fine for authenticated user. however it doesnt display details when i visit details view . for example when i visit…
Ashok
  • 976
  • 3
  • 15
  • 32
7
votes
4 answers

How can I get all users an object has specific permissions to in django guardian?

There is from guardian.shortcuts import get_objects_for_user But what about from guardian.shortcuts import get_users_for_object Thanks.
Natim
  • 17,274
  • 23
  • 92
  • 150
7
votes
1 answer

Django-guardian - where to assign default permission on object creation

I am starting an app that has a complex permission structure that will inevitably be managed by the users themselves. I have the following permissions in the model: class Meta: permissions = ( ('can_view', 'View project'), …
jondykeman
  • 6,172
  • 3
  • 23
  • 22
7
votes
1 answer

Invalid Literal error when adding a user permission to a Django user object

I've got a model defined in my Django app foo which looks like this: class Bar(models.Model): class Meta: permissions = ( ("view_bar", "Can view bars"), ) I've run manage.py syncdb on this, and sure enough, it shows…
Chris B.
  • 85,731
  • 25
  • 98
  • 139
6
votes
1 answer

object-level permissions django

How do you ensure that a User can only edit objects they've created? What's the best way to set this up? I'm using django-rest-framework and wondering if there's a way I can restrict users from viewing/ editing objects they don't 'own'. class…
9-bits
  • 10,395
  • 21
  • 61
  • 83
6
votes
2 answers

How to avoid typos in django's permission strings

According to the docs custom permissions can be created and used like this: class Task(models.Model): ... class Meta: permissions = ( ("view_task", "Can see available tasks"), ) Using the…
guettli
  • 25,042
  • 81
  • 346
  • 663
6
votes
2 answers

Show group members in Django Admin

Is it possible to set Django Admin page to show which user is in which group? And is it possible to be able to add a user into a group using the Django Admin page? If yes, how? Now, I'm adding programmatically customers into customers group and…
Milano
  • 18,048
  • 37
  • 153
  • 353
1 2
3
28 29