Questions tagged [django-guardian]

django-guardian is an implementation of per object permissions on top of Django's authorization backend

django-guardian is an implementation of per object permissions [1] on top of Django's authorization backend,

Online documentation is available at https://django-guardian.readthedocs.io/.

140 questions
3
votes
2 answers

Working with Django Model Permission raises DoesNotExist error

I have some problems with django guardian. I have a news model defined class News(models.Model): title = models.CharField(_('Title'), max_length=255) slug = models.SlugField(_('Slug'), unique_for_date='pub_date',) objects =…
sogeking
  • 1,216
  • 2
  • 14
  • 45
2
votes
0 answers

Defining and assigning roles per object in Django

What could be a good way to define roles using django-guardian? I would like to set to a users groups of permissions over an object, and so that permissions can be added to the role and be accesible to all the users associated with a particular…
2
votes
1 answer

How to use django-guardian in customized user model

I am using django-guardian to check the user's object permission. And in my special case, I have extended user model. In my models.py I have extended user model like this: enter image description here class User(AbstractBaseUser): email =…
2
votes
1 answer

Override get_queryset based on django-guardian permissions

I am trying to override get_queryset based on the object permissions, which the users have from django guardian, so that only the objects are visible, which the users have permissions for. def get_queryset(self, request): if…
dsax7
  • 1,333
  • 22
  • 36
2
votes
1 answer

Set object-level permission with django-rest-framework

Trying to manage django-guardian object-level permissions with django-rest-framework the most cleanly and canon possible. I want to assign a read permission (module.view_object) of an object to to the user making the request when performing a…
Luke Skywalker
  • 1,464
  • 3
  • 17
  • 35
2
votes
1 answer

Django-Guardian - Restrict group access to class

I have followed the user guide from the django-guardian docs to set up django-guardian. This has given me the possibility to control whether a group can view a specific class or not. This is the example from the django-guardian docs with an added…
Wessi
  • 1,702
  • 4
  • 36
  • 69
2
votes
1 answer

Alternatives to django-guardian get_objects_for_user

We are successfully using django-guardian and django-rest-framework on a project. However, the standard way to get objects for a certain user with certain permissions seems very slow when the user has 1000's of objects with the required permissions…
Guy Bowden
  • 4,997
  • 5
  • 38
  • 58
2
votes
1 answer

Model design for a user who can have roles at multiple organizations

I need a Django model where a User can have a Function with any number of Organisations. His permissions (change, view, delete) with the organization are determined by his Role. I am pretty sure I only need an "admin" and a "member" role. This would…
Roy Prins
  • 2,790
  • 2
  • 28
  • 47
2
votes
0 answers

django guardian integrity error with assign_perm

I am attempting to use guardian with my own User model. Yes, I know, there is no guarantee guardian is going to work with another User model :-). But I would appreciate any help in attempting to understand this to see if I can get this going. My…
brechmos
  • 1,278
  • 1
  • 11
  • 22
2
votes
1 answer

Django grant permissions on/ after saving object

I have a Django model which includes specific permissions. I want to be able to assign permissions to those users in the assigned_to field. I am using django-guardian to manage the permissions. from django.db import models from…
Darwin Tech
  • 18,449
  • 38
  • 112
  • 187
2
votes
1 answer

Django-guardian. How to filter permissions list?

I'm using django-guardian to manage my permissions. Default each model has 3 perms: add, change, delete. If I add my own permission e.g. view, I will have all 4 in User managment tab and all 4 in model-object managment tab. I know that is possible…
zie1ony
  • 1,190
  • 2
  • 14
  • 33
2
votes
2 answers

Why is django-guardian's assign_perm giving me a DoesNotExist error?

I am attempting to assign a user permissions to a task using django-guardian and I'm getting errors. Inside of my Task class in task/models.py, I have: class Meta(BaseModel.Meta): permissions = ( ("task_view", "Person can view task…
Foo Party
  • 596
  • 1
  • 4
  • 13
2
votes
1 answer

django-guardian - meaning of (User, 'username', 'username')

Can anyone explain me, what does (User, 'username', 'username') and (User, 'username', 'username', 'groups__name', 'group_name') mean? @permission_required('auth.change_user', return_403=True) def my_view(request): return…
Tom Tichý
  • 1,065
  • 1
  • 12
  • 19
2
votes
1 answer

Django South migration cannot access custom model Meta attribute

I've got a Django app I've created which uses both Django Guardian to manage object-level permissions, and Django South to manage migrations. I've created a model mixin which allows models to define object-level permissions to be assigned as they…
Greg Hinch
  • 807
  • 2
  • 8
  • 23
2
votes
1 answer

What can Django-Guardian do that is not possible by Django Auth Permissions?

What are the features that django-guardian provides that are not already provided by django auth's permissions? Here are the features listed by django-guardian's documentation: Object permissions for Django AnonymousUser support High level…
ksuralta
  • 16,276
  • 16
  • 38
  • 36
1 2
3
9 10