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

Handling exceptions in permission classes

I am using Django REST Framework with simple JWT, and I don't like how permission classes generate a response without giving me the final say on what gets sent to the client. With other class-based views not restricting permissions (login,…
0
votes
1 answer

How to revoke permission to edit Admin User in django admin

I have a custom user model, and I'm able to create groups without giving necessary permissions. I created a group by giving permission to view and change users. I added a staff user to that group without escalating them as an admin user or a…
0
votes
1 answer

Apply Django permissions based on Request and Model

TL;DR; Is there anyway in Django, to automatically check the permissions of a User/Request against default permissions (add,change,view,delete) before executing a query? I'm pretty new to Django and what I'm trying to achieve is utilizing Django's…
Ravexina
  • 2,406
  • 2
  • 25
  • 41
0
votes
2 answers

How to add custom field to auth_permission model in django?

I am working with auth_permission model and to add extra fields in this model. class Permission(models.Model): name = models.CharField(_('name'), max_length=255) content_type = models.ForeignKey( ContentType, …
Sohaib
  • 566
  • 6
  • 15
0
votes
2 answers

How to Add Delete view according to role based in django

Hi I am working on Tree Structure role. There are 4 roles 1.A 2.B 3.C 4.D Where A can add,delete view B,C,D and B,C,D cannot delete or view A. B can add,delete view C,D but can cannot delete A and its parent. Similary for C and D. I can create…
0
votes
1 answer

How to return nested data according to user role in django rest framefork?

I have model which is connected to another model with foreign key, I have ApiView in django. Also, I have users with admin,moderator , and some roles. What I want is when Admin sends get request bring all nested data, when moderator sends get…
0
votes
0 answers

Django same set of permissions for different models

So I've got two models structed like: class DataSheetsCluster(models.Model): """ Represents a group of datasheets made by the owner. Has it's own icon, name and description. A parent can only have one owner at a time. """ …
Aryan Iyappan
  • 323
  • 1
  • 3
  • 15
0
votes
0 answers

Where to put Django permissions logic?

I have a 'View' which is mostly contain a 'Form', I need one User-Group with edit-permission to see it and edit form, And another User-Group with just view-permission to only can view information, And they can't edit information. What is the best…
0
votes
1 answer

Django Rest Framework Custom Permission does not recognize user

I am trying to enforce a custom permission in DRF. Specifically, I am trying to see whether a user is authorized to access an object. I adapted this solution from another post here but it does not quite work for me. The permission class always…
Philipp K
  • 193
  • 2
  • 18
0
votes
0 answers

How do I give permission to only specific users to edit model fields in Django rest?

So I building a blog rest_api which has models class Post(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) text = models.TextField() approved = models.BooleanField(default=False) …
0
votes
0 answers

Why user.has_perm return false although request.user.get_all_permissions() and request.user.get_user_permissions() returns permission?

Hey I have a little problem with my permission in Django. In my admin panel everything seems be ok, user has all needed permission but if I try to use @permission_required decorator or has_perm test return 'false' Here is my code: My user…
Matix
  • 25
  • 4
0
votes
1 answer

How to use has_object_permission to check if a user can access an object in function based views

I have a note object which can be accessd from notes/{pk}. If the method is GET or a read only method I was to allow anyone access to the note as long as the note is public (note.is_private = False) I've implemented this as: @api_view(['GET',…
0
votes
1 answer

Django auth permissions

How can I make the Django model available by default, for users (Staff = True), to make available CRUD actions in the admin panel? I wrote some code based on the Django authentication system: from django.db import models from…
0
votes
1 answer

How to create some group of user without password in django?

I am developing multivender ecommerce site in django. In which, i dont want to authenticate some group of user i.e. customer with password but want to authenticate venders with password. How can i do that?
0
votes
1 answer

Django Custom Permission method or decorator

I am many views and more than one user type. I want some views that can be seen by specific user types and other users cant see this. For example, only company see this views and for this i did that like this below: @login_required def…
user12551055