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
1
vote
0 answers

Django/guardian default permission

What I would like to do is to set view permissions of certain parts of the site depending on the user (that is easy using permissions and guardian). I have a set of buttons across the top of the page. For one or two buttons I want to set…
brechmos
  • 1,278
  • 1
  • 11
  • 22
1
vote
1 answer

Restricting ModelChoiceField choices in the admin panel

I'm creating a voting app that makes use of the admin panel (along with django-guardian), where the relevant chain of ForeignKeys between the models is: Vote => Choice (the choice being voted on) => Survey (the survey containing the choice) => User…
Gravity Grave
  • 2,802
  • 1
  • 27
  • 39
1
vote
1 answer

In django-guardian, how can I get all objects user has any permissions for

In django-guardian, how can I get all objects user has any permission for (through groups as well). There is a shortcut to get all users having any permission over an object, but I am searching for all objects a given user has any permission over.
Mitar
  • 6,756
  • 5
  • 54
  • 86
1
vote
1 answer

optimizing django architecture to speed up list view within admin

I am developing a medium site for my company, with large amounts of data (research publications, hundreds of employees, etc.) and security constraints which made me think of using django-guardian to handle object permissions. But now I'm realising…
sogeking
  • 1,216
  • 2
  • 14
  • 45
1
vote
1 answer

Python Django (Guardian): editing data depending on an m2m-field in my model

I am really having troubles getting my Admin-interface working. I have a Model and within that model a m2m-field to Group: from django.contrib.auth.models import Group class Lecture(models.Model): .... allowed_groups =…
Magda
  • 1,218
  • 3
  • 14
  • 31
1
vote
0 answers

django-guardian - AUTH_USER_MODEL refers to model 'auth.User' that has not been installed

I'm trying to get django-guardian to work with my app. I followed the installation and configuration steps in the django-guardian documentation. It fails to assign permissions with the "ImproperlyConfigured: AUTH_USER_MODEL refers to model…
user3138929
  • 369
  • 5
  • 18
1
vote
1 answer

Using django-filter together with django-guardian

I fail at making django-filter and django-guardian work together. What I need is an ItemsFilterView that lets the user list and filter all items that she has permission to view. Below are the parts of my code of which I think are most relevant. I…
hielsnoppe
  • 2,819
  • 3
  • 31
  • 56
1
vote
1 answer

understanding guardian.shortcuts.get_objects_for_user

I have trouble understanding the behavior of the django-guardian function get_objects_for_user. I am assigning group object permissions, but those permissions do not seem to exist for get_objects_for_user. >>> u =…
sogeking
  • 1,216
  • 2
  • 14
  • 45
1
vote
1 answer

Using guardian's assign_perm in a south migration

I can't get django-guardian assign_perm to work in a south datamigration ... the reason it is not working seems to be because guardian is not using the frozen ORM. How can I get other apps in general and django-guardian specifically to use frozen…
Pykler
  • 14,565
  • 9
  • 41
  • 50
1
vote
1 answer

How to save the permissions after assigning them to a user in django 1.3

I have a set of permissions, from which I am assigning some specific permissions to the user. i am using this: assign('view_userreports', , ) The permission is assigned successfully, but when I goto admin interface to…
MHS
  • 2,260
  • 11
  • 31
  • 45
1
vote
0 answers

django-guardian get_objects_for_group

What is the best way to integrate row level permissions into all models, so that listing would cause a simple JOIN? I wish to have a shortcut like this one to return me a queryset from guardian.shortcuts import…
user537723
  • 93
  • 1
  • 9
0
votes
0 answers

Assigning model1 permissions to a model2 instance in Django using Django Guardians

I am using Django Guardians in my project and it works fine so far, but there is some problem: I need to assign permissions from model1 to the instance of the model2. Real example: The shop has some contracts and the shop owner wants to assign his…
0
votes
1 answer

Django Rest Framework Model Viewsets 'POST' method not appeared in ALLOW methods after explicitly allowing it

Fairly new to it but have after trying out many different solutions, I still get the following problem where the POST html form would not appear (and POST method not allowed) as seen below, all while using a root superuser model.py class…
0
votes
0 answers

Django Guardian with Data Migration (adding Anonymous user to public group)

I'm trying to perform a data migration in an app. I would like to add the anonymous user (the django-guardian AnonymousUser) to a public group. Somehow the user does not exist when i'm running test (test database migrations fail with user matching…
Eric Muijs
  • 29
  • 6
0
votes
2 answers

What's the most pythonic way to test if obj has any permission from a list

In both Django and Django Guardian it's simple to test if a user has a permission: user.has_perm('app.can_eat_pizzas') It's also easy to test if it has all permissions: user.has_perms(('app.add_student', 'app.can_deliver_pizzas')) What's the most…
alias51
  • 8,178
  • 22
  • 94
  • 166