Questions tagged [django-permissions]

django-permissions is a pluggable django app that provides per-object permissions for Django based on roles

django-permissions is a pluggable django app that provides per-object permissions for Django based on roles.

431 questions
0
votes
0 answers

How to create user groups for permissions within code (not in admin)

I'm wanting to create user groups for permissions and am wondering how to do this in the code as it sounds like the more proper way to do it (or not?). I have done some searching and have found a few completely different pieces of code, but I am not…
horse
  • 479
  • 7
  • 25
0
votes
1 answer

Add prefetch_related() to Django Authentication backend

In my project I have both Group and Custom User Based Permissions. I have a custom authentication backend which essentially checks to see if the user has group permissions and then sees if they have any revoked permissions which need to be removed…
ViaTech
  • 2,143
  • 1
  • 16
  • 51
0
votes
1 answer

How to add more features to user permission in django?

I am new to django. I want to edit default user auth_permissions. More precisely I want to add an integer field in addition to "label", "code" features to distinct permission types (like strong, moderate and etc.). So far I could not find anything…
0
votes
0 answers

What is the proper way to write permission_required in a view in django?

I am trying to implement a web app in django where I have a class based view that inherits from PermissionRequiredMixin and generics.View. Here is an example model: class SomeModel(models.Model): # Here I will put some model attributes …
Ambitions
  • 2,369
  • 3
  • 13
  • 24
0
votes
1 answer

Get django permissions for logged in user to show/hide menus according to user role

I am new to django and am working on a django project, where I want to show/hide menus in accordance with the permissions a logged in user has. I am using Django Rest Framework and JWT. I did not find any url in rest_auth.urls to fetch all the…
0
votes
1 answer

Create project-level permissions at project initialization

When I first run manage.py migrate on a Django project, I would like the database to be initialized with some extra permissions. I have seen here that this can be done at the app level, in the apps.py files. However the permissions I would like to…
mimo
  • 2,469
  • 2
  • 28
  • 49
0
votes
1 answer

ValueError: Cannot query "": Must be "Group" instance

I create custom user and Group model inherit the Abstract user modeland auth Group model. But I create the staff member and give some permission the same error trigger. then check the user permission the same error trigger. Put some code or error…
0
votes
2 answers

Django Rest Framework Permissions not being called for Detail and List View

I created this custom permission class and it does not seem to be called when I make a request from the view. I event set it to return false and requests are still successful. Tried placing a print statement to see if there would be any output but…
user9469766
0
votes
2 answers

How to test is user is one of the groups in a list of groups

I have a list of groups, and I want to test if the user belongs to any one of the groups. I can get a list of user's groups: user_groups = user_object.groups.all() And I can use sets: if not set(user_object.groups.all()).isdisjoint(group_list): Is…
Granny Aching
  • 1,295
  • 12
  • 37
0
votes
1 answer

Give permission according to data in Django

I'm working a project wherein there are multiple institutions. All the institutes have the same hierarchy of students, teachers and staff members. My problem is how do I keep the institutions apart? For example: the data profile of student from…
Mithil Bhoras
  • 694
  • 1
  • 7
  • 22
0
votes
1 answer

Configuring user permissions with django

I wrote an API service with Django. I have authorized the user to list only clients via django admin panel. When I enter the django admin panel with the user name I authorize, there is no problem in the authorization. But when I access the api…
0
votes
1 answer

How to show in the Django administration only the data corresponding to the current user's company

I'm developing a project in Django. I have several registered companies, and all models are based on the company. My question is this: how can I do that when a user enters the administration can only see the data of their company. models.py class…
0
votes
1 answer

Confusion about the django permission and group model?

For example I create permission like this: Permission.objects.create(name='Can add',codename='can_add',content_type=1) Now if I want to apply this permission in some view I need to use permission_required decorator like…
D_P
  • 802
  • 10
  • 32
0
votes
1 answer

How to get permission associated with view programmatically

In Django I have a function that provides a list of all URL Patterns for my system. I am attempting to create a search feature that shows users links to a list of urls that they have permissions to view, but I cannot seem to figure out how to grab…
ViaTech
  • 2,143
  • 1
  • 16
  • 51
0
votes
0 answers

What will happen if i create a group and didn't add a specific permissions to it?

I have two groups 'user' and 'moderator' with no specific permissions added (Chosen permissions empty). I have also three views to add/edit/delete objects, user can only add whereas moderator can edit/delete views.py class…
DAMAR225
  • 1,993
  • 1
  • 13
  • 22