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

Django REST Framework: allow any user can edit any data (remove object_permission)

I am using Django REST Framework's viewsets.ModelViewSet to list, create, update and delete table rows. For the following Tasks model it works fine. But it only allows to list, create, update and delete of own entries (i.e. resource owner) or the…
1
vote
1 answer

Loading django user groups from json

I am trying to make multiple user groups. Each groups has a set of seperate permissions. Is there a way to initialize a django project with user-group permissions from json. I am looking for methods like python manage.py loaddata user_groups.json.
Sudheer K
  • 1,244
  • 2
  • 18
  • 31
1
vote
1 answer

Django permissions analysis

Is anyone aware of a programmatic way of analysing a codebase to see which permissions each view is protected by? I'd like to be able to run a regular report on a site to inform us which views are available and who can see them etc. rather than…
bodger
  • 1,112
  • 6
  • 24
1
vote
2 answers

membership management in Django

I'm writing my first Django application in Django 2.0 My application has two types of membership level Free Users Paid Users Also, there in the application I want certain function/views disabled for Free Users and hide elements in template based…
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
1
vote
1 answer

Django Signal Triggered But Not Saving

Exactly like the title says. The post_save receiver is being triggered, and permissions are being changed in these methods, but they remain unchanged on the admin page. Here's the model I'm using, stripped to just the part in question. from…
1
vote
2 answers

Django - allowing specified user to modify certain model fields

I need to allow a certain user, who is specified in the model, to modify a few of the model's fields. I know I need to create a permission class, which will control the whole process, but I have no idea how to do that. Here's the code sample: class…
1
vote
1 answer

How to deny permission to a user of one kind from accessing the view of other user through url in django?

In my project, I've got different types of Users like this: User |-Client |-Employee |-Technical Manager |-Service Manager |-Production Manager No user can access the view of other user by url. A client cannot access profile of a…
sphoenix
  • 3,327
  • 5
  • 22
  • 40
1
vote
1 answer

Django Rest Framework permission on a Foreign key item

I have two models that have a relationship like so: class ManuscriptItem(models.Model): """Represents a single manuscript's content""" author = models.ForeignKey('accounts_api.UserProfile', on_delete=models.CASCADE) title =…
1
vote
1 answer

Admins, users and groups in different organizations in Django

I'm creating a Django app, aimed at organizations that will have several users. So in the models, I have organizations and users, and organizations should be independent. First user of an organization to signup will be admin, next users to signup…
1
vote
0 answers

Django user has_perm returning false even though group has permission

I'm running into a problem where I've created a Group with certain permissions, and successfully added a user to that group, but when I check user.has_perm with that permission, I'm getting False. I've even tried things like saving the user and…
warchinal
  • 229
  • 2
  • 14
1
vote
2 answers

How to customize DjangoObjectPermissions?

Hi I am following this example of using the DjangoObjectPermissionsFilter. I want to create class SampleModelPermissions(permissions.DjangoObjectPermissions) so that it satisfies the following description in my "self-documented" DRF API: This is…
1
vote
1 answer

How to enable a user to view the django admin home page if nothing but a custom view permission in given to the user?

By adding the following code in one of my models, I was able to add a view permission to the model. class Meta: default_permissions = ('add', 'change', 'delete', 'view') I have created a user in django-admin and given only view permission. I…
Naman Sharma
  • 179
  • 1
  • 1
  • 12
1
vote
2 answers

Django PermissionRequiredMixin redirect to login template with message

I got this view and I'm using PermissionRequiredMixin on it...it works fine but when I redirect to login template (set in settings LOGIN_URL) I need it shows a message there like "You don't have permission to do this". Any idea how to do it without…
jsanchezs
  • 1,992
  • 3
  • 25
  • 51
1
vote
1 answer

Adding permissions when user is saved in Django Rest Framework

I'm creating an instance of a User object. The creation itself is a standard User.objects.create_user call and that works ok - user is created. After that, I'm trying to add a few permissions to him or her: for name in ('view_restaurant',…
Marek M.
  • 3,799
  • 9
  • 43
  • 93
1
vote
1 answer

Django - How to use specific custom permissions in views and templates?

For my "tutorial app", I created some specific permissions after creating an object. Only the object's author have to be able to update or delete it. I'm a beginner and I'm here to learn, if my methods are ugly be tolerant. Here my views.py class…
Léo Mouyna
  • 25
  • 1
  • 8