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
0
votes
0 answers

How to fix 'Permission matching query does not exist.' in Django

I'm creating a web system for a school in Django, for that I decided that I would use Django-Gurdian for object based permissions, and also I set up a signal after migration to create default groups like: all-students, all-teachers, etc... And I am…
0
votes
1 answer

Check object permission for user with global permission

How i can check permission to object for user with global permission ? joe = User.objects.get(username="joe") assign_perm('parse.show_company', joe) # assign global permission company = Company.objects.get(id=id) joe.has_perm('parse.show_company',…
0
votes
0 answers

How to implement Django SSO with custom user model and object permission (EX/django-guardian) in multiple projects

I tried to search and study some information on the google, but I couldn't find the good solution. I have several Django projects and want to create "Member" project store user information which implement Single-Sign-On(SSO) feature…
max533
  • 23
  • 8
0
votes
1 answer

Modifying ModelViewSet's queryset for many2many relation query based on django-guardian permissions

I got 2 models which are connected as ManyToMany as you can see below. The thing i'm trying to achive is; serve people to users only when a user has a at least view right on the list that person belongs. Here is my simplified models; class…
0
votes
0 answers

Complex Django permissions

I'm working with the following models in a django project. The effective relationship is that a District can have multiple Schools, a School can have multiple Students, and a Student may have multiple Cases. class District(models.Model): name =…
Chandler
  • 1
  • 2
0
votes
1 answer

Guardian and custom user model: IntegrityError on migration, creating anonymous user

I have this model file with custom user defined in it. class CustomUser(AbstractBaseUser,PermissionsMixin, GuardianUserMixin): email = models.EmailField(max_length=50, verbose_name='email address', unique=True) first_name =…
Silasi
  • 129
  • 2
  • 10
0
votes
2 answers

How can I add automatically CRUD permissions to a django model inside the Meta class?

Imagine I had the following model class Post(models.Model): name = models.CharField(max_length=20) body = models.TextField() class Meta: permissions = permission_generator() and what I want is that the permission_generator()…
0
votes
1 answer

code in save_model executed on second save, not first

i defined a save_model in my UserAdmin to change object level permissions for users. class UserAdmin(BaseUserAdmin): def save_model(self, request, obj, form, change): obj.save() allprojects = Project.objects.all() …
Rubick
  • 139
  • 3
  • 11
0
votes
0 answers

setting permission for only one object using Django-guardian and Flatpages

I'm trying to use Django-guardian to apply permissions to specific flatpages. we have a number of flatpages on our site, and in most cases the django-auth works for what we need. However, we want to add object level permissions to some of the…
0
votes
2 answers

display only some objects in change list of a model in django

I am creating a Django application for multiple universities. Here are the Model classes I have used. class Institute(models.Model): name=models.CharField(max_length=200) def __str__(self): return self.name class…
0
votes
1 answer

Django-Guardian Permissions - Set permissions for objects in a on-to-many relationship

I have the following models: Project: class Project(models.Model): project_name = models.CharField(max_length=100, unique=True) SearchCodes: class SearchCode(models.Model): project = models.ForeignKey(Project, on_delete=models.CASCADE) …
beginAgain
  • 211
  • 4
  • 17
0
votes
1 answer

How can control the items in view class queryset?

class ModelListCreateView(GetQuerysetMixin, generics.ListCreateAPIView): queryset = get_objects_for_user(self.context['request'].user, 'model.view_model') serializer_class = ModelSerializer permission_classes =…
ArdentLearner
  • 712
  • 7
  • 20
0
votes
1 answer

django guardian importerror but other examples work

First off, I am new to both django and python. I am working on an existing project that is using django-guardian 1.3.2. I verified the server this app is deployed is also using 1.3.2 via pip list. I am trying to understand the cause of an…
Josh C.
  • 4,303
  • 5
  • 30
  • 51
0
votes
0 answers

Adding View_Group Perm to groups table using Django Rest Framework and Guardian

I am writing an application using Django 1.9, Guardian and Django Rest Framework. I am trying to add a new perm (view_group) to groups. This new perm will control what groups logged-in user can see when calling the backend. I am using…
0
votes
1 answer

Django Guardian Permission Error: Argument pk was not passed into view function

I have a Model called Message that I use django-guardian for object level permission. The idea is that both the from_user and to_user in a message instance should have the can_view_message permission. This function is to display a list of messages…