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

Using DjangoObjectPermissionsFilter to filter objects of user using django-guardian

I was able to setup django-guardian and my django-rest-framework project as the example in drf docs, but I'm failing to achieve the behavior that I want. Could someone please point out if I'm doing something wrong or if what I want can't be done…
ldavid
  • 2,512
  • 2
  • 22
  • 38
5
votes
2 answers

django-guardian how to make object inherit permissions of related object?

I got two models: class ContactGroup(models.Model): name = models.CharField(max_length=40) class Meta: permissions=(('view_group_contacts', 'View contacts from group')) class Contact(models.Model): name =…
Lord_JABA
  • 2,545
  • 7
  • 31
  • 58
5
votes
2 answers

Restrict access to only owned content django

I'm writing an API using django-tastypie. I have two custom permisions issues that I'm hoping django-guardian can fix. I have two user groups Clinicians and Patients. Clinicians should be able to access the objects belonging to only their Patients…
Prydie
  • 1,807
  • 1
  • 20
  • 30
4
votes
1 answer

Django guardian: How to give all users the permissions of the anonymous user

I am using django-guardian to implement per-object permissions in my Django project. I've run into an issue where registered users are unable to view objects that anonymous users are able to view. I had thought that if the anonymous user has a…
Joseph
  • 12,678
  • 19
  • 76
  • 115
4
votes
2 answers

Django: Can't override admin templates when they are already overridden?

To add some content to a Django admin view of a model, I want to override the change_form.html template. According to the documentation I would need to create a file change_form.html in a the folder /project-path/templates/admin/appname/modelname/.…
tomka
  • 1,275
  • 1
  • 11
  • 17
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
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
3
votes
0 answers

Implement row level permissions in multiple database django

I have to implement row-level permissions(object level) in Django, I find out that Django-guardian is a good option for this but problem is that I am using multiple databases in project one database has user table while another database has the…
3
votes
0 answers

field level permission in django

In django, I can use django-guardian for object level permission for user and groups. But what if I want to set field level permission? Lets say I have a model as below: class Attribute(models.Model): name = models.CharField() reg =…
cjahangir
  • 1,773
  • 18
  • 27
3
votes
1 answer

Row based permissions in Django

I have a simple Django model which looks roughly like this: from django.contrib.auth.models import Group from mylogapp.models import LogType class Log(models.Model): responsible_group = models.ForeignKey(Group) description =…
guettli
  • 25,042
  • 81
  • 346
  • 663
3
votes
1 answer

Clone all object permissions in django-guardian / inherit from ForeignKey

I have an app with model hierarchy in which I need underlying objects to have the same permissions as the parent object (not only their definitions/codenames, but also per-user and per-group rights). Django-guardian seems to have only functions…
M. Stefański
  • 319
  • 2
  • 8
3
votes
1 answer

Django permission belongs to group, but user on that group has no group's permission

I decided to not use django-guardian because If my customer delete/create Group I have to add more overhead on my ModelManager to transfer the existing permissions to new group. Therefore let the instances got filtered by filter_queryset through…
joe
  • 8,383
  • 13
  • 61
  • 109
3
votes
1 answer

Django REST framework: using object-level permissions without model-level permissions

I have a Django project with API based on the Django REST framework. Recently I've enabled object-level permissions with the use of django-guardian. However I'm not using model-level permissions framework in my project yet (and until this moment I…
Warwick
  • 1,200
  • 12
  • 22
3
votes
1 answer

How to reference ContentType in Django's fixture?

I'm writing tests for Django project with django-guardian. Fixture for permissions look like: - fields: content_type: 10 object_pk: '2' permission: 22 user: 1 model: guardian.userobjectpermission pk: 1 Is it safe to reference…
Domen Blenkuš
  • 2,182
  • 1
  • 21
  • 29
3
votes
2 answers

Django admin model add_view: how to remove "save and add another" buttons?

I was able to remove the "save and add another" and "save and continue editing" buttons by implementing the following code: # At the start of my admin.py file I have: from django.contrib.admin.templatetags.admin_modify import * from…
1
2
3
9 10