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
2
votes
1 answer

Better to use 3rd Party Row-Level Permission App or to Filter Query Results in a Django View?

I am writing a Django app that involves the creation of documents. I have a few requirements: Check to see if the user is able to view any documents at all. If the user is allowed to view documents, only allow them to view documents they have…
Ben S
  • 1,407
  • 1
  • 13
  • 27
1
vote
2 answers

ModelNotFoundError: No module named 'guardian.shortcuts'

I am trying to run a Django project, I tried to import assign_perm and remove_perm from guardian.shortcuts (code listed here: from guardian.shortcuts import assign_perm, remove_perm). and got an error: ModuleNotFoundError: No module named…
RA.IBOY
  • 69
  • 1
  • 7
1
vote
1 answer

Django guardian several permissions with get_objects_for_user

If I pass in one permission at a time get_objects_for_user works fine >>> projects = get_objects_for_user(alvin, 'view_project', klass=Project) >>> projects ]> >>> projects = get_objects_for_user(alvin,…
toni
  • 443
  • 5
  • 14
1
vote
0 answers

Django-guardian has_perm("codename", obj) is False even if group has the permission

I'm trying to implement django-guardian permissions in my project. In the TestCase below, I assigned view_income permission to staff group. That means, also user_c has the permission. The problem is that self.user_c.has_perm("view_income", income)…
Milano
  • 18,048
  • 37
  • 153
  • 353
1
vote
0 answers

How do I best restrict by user and by data model using Django?

I'm using django-guardian and I encountered some issues with the default mixins. And I want to know if there's a better way to do this. GitHub Link: https://github.com/iaggocapitanio1/django_homepage Problem: If I want to limit access at both the…
1
vote
1 answer

Filter queryset accouring to related objects in django

I used django-guardian library, I want to create Manager to filter objects according to user permission. So for-example: from guardian.shortcuts import get_objects_for_user class WithUser(models.Manager): user_obj = None def…
1
vote
0 answers

How to remove all permissions from a user in Django Guardian?

I'm trying to reset my user permissions to assign new objects permissions to my user. how to achieve that ? For Example: having 3 chained models School & Grade & StudentRecord Models.py: class School(models.Model): name =…
Poula Adel
  • 609
  • 1
  • 10
  • 33
1
vote
0 answers

BasicAuthentication does not authenticate user when checking permissions

I want to use DRF's rest_framework.authentication.BasicAuthentication to develop my SPA with a dev server while consuming data from a locally running backend. I included rest_framework.authentication.BasicAuthentication in settings.py. I have a…
nehalem
  • 397
  • 2
  • 20
1
vote
0 answers

how assign permission different model to one object?

i have this model i need to assign permission Relation model to object TableRelation model because i want have one model permission class Relation(models.Model): title = models.CharField(max_length=100) layer =…
Ali Kafy
  • 11
  • 2
1
vote
1 answer

How to add group choices in the Object Permissions form of the admin interface with django-guardian?

Using guardian in a django project, I want the admins to be able to assign object permissions over the admin interface. With guardian this is possible, but the Object permissions form in the admin interface, the Group field is a TextField. How do I…
talz
  • 1,004
  • 9
  • 22
1
vote
1 answer

Django permissions via related objects permissions

I am relatively new to Django and I'm looking for some guidance in how to setup permissions in a certain way. Basically I have an app that consists of a couple of models similar to this: class Project(models.Model): name =…
1
vote
2 answers

Django : How we can add extra fields on the Group model

Hi I am working on django permissions system with Django 2+ . And I want to add extra fields inside the Group model in Django but right now I have no idea how to do that. I tried something like: models.py from django.contrib.auth.models import…
1
vote
0 answers

Storing vs computing Permissions in Django Rest Framework Views

Suppose in an application there is a model "Service". There is also an "Orders" model which takes care of "User" purchases. class Service(models.Model): name = models.CharField(max_length=10) class Order(models.Model): service =…
1
vote
0 answers

Django guardian migration NodeNotFoundError after MIGRATION_MODULES defined for auth

I used django guardian in my project. For a reason, I added a new field to django group model with this code: if not hasattr(Group, 'project'): project = models.ForeignKey(Project, on_delete=models.CASCADE, null=True, related_name='groups') …
kamilyrb
  • 2,502
  • 3
  • 10
  • 25
1
vote
0 answers

Django Object Permission "django-guardian" chnage Admin object permission UI

I want to change some Admin UI in Object Permission(Django-guardian). I only want to Given Group Permission to the respective Obj and search the group name replace by Show All Group and select the Group. How to customize the Admin Panel for…