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
20
votes
5 answers

Adding django admin permissions in a migration: Permission matching query does not exist

I wanted to add some groups and assign permissions to them in a manually written migration but if I run it on a clean DB it creates permissions only after running all migrations. I've found this ticket:…
int_ua
  • 1,646
  • 2
  • 18
  • 32
20
votes
5 answers

row level permissions in django

Is there a way to do row level permissions in django? I thought there wasn't but just noticed this in the docs: Permissions can be set not only per type of object, but also per specific object instance. By using the has_add_permission(), …
9-bits
  • 10,395
  • 21
  • 61
  • 83
17
votes
1 answer

Django rest framework group based permissions for individual views

I am using DRF for writing API's. I would like to give different permissions for each view in my Modelviewsets. I have two groups(customers and staff). I have filtered them as Isstaff and Iscustomer in permissions.py. class…
17
votes
4 answers

Field Level Permission Django

Today i came up with a requirement where i need to implement field level permission so looking for the best possible way. class ABC(models.Model): field1 = ..... field2 = ..... field3 = ..... Create two groups(A and B) and…
djangobot
  • 257
  • 1
  • 2
  • 11
14
votes
2 answers

How to add django rest framework permissions on specific method only ?

I have following functions in rest API for User model. I want to set AllowAny permission on only POST request. Can someone help me out. class UserList(APIView): """Get and post users data.""" def get(self, request, format=None): …
Ankit
  • 326
  • 1
  • 7
  • 18
13
votes
3 answers

Django: Adding Permission to an Specific Model Instance

I am looking for the best way to implement user permissions to allow users to edit specific model instances. For instance, I have such two models: model RadioChannel(models.Model): name = models.CharField(max_length=150, unique= True) number…
Hellnar
  • 62,315
  • 79
  • 204
  • 279
13
votes
3 answers

How to add a permission to a user/group during a django migration?

I would like to execute the following migration: # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.contrib.auth.models import Permission from django.db import migrations from django.conf import settings from…
13
votes
3 answers

Django: Permissions based on Model Instance

I have a model class Project and for each model instance, there should be a 'group' of users who may edit that instance. I guess I could add another model class called ProjectEditor to add those editors. Is there a better way of implementing this?…
user290043
13
votes
1 answer

Giving default permissions or a default group to new users

Default behaviour seems to be new users have no permissions and no groups. However I'd like not to have to manually grant every single new users basic permissions, and I'd assume they'd like not to have to wait for me to do so. How should I assign…
jozxyqk
  • 16,424
  • 12
  • 91
  • 180
13
votes
3 answers

Django model permissions not picked up on admin

I've added permission to my model and I would like to create a group in admin that uses this permission. The problem is that the new permission is not listed in the permissions list. is there something I need to do to add it to that list? class…
user2323711
  • 843
  • 1
  • 7
  • 13
12
votes
1 answer

Extend django Groups and Permissions

I've been searching Google and Stackoverflow for the last 3 days now and couldn't find anything similar. I'd like to extend or use the django groups and permissions. Let's say we got some Projects with different Teams and Users. class…
Thomas Schwärzl
  • 9,518
  • 6
  • 43
  • 69
12
votes
2 answers

Add object level permission to generic view

The situation is pretty simple: I'm writing a multi-user blog system. The system should prevent non-owner to edit or delete a blog post. In my view I use generic view. class BlogUpdateView(UpdateView): ... I know I should use @method_decorator to…
Xinghan
  • 255
  • 1
  • 3
  • 8
11
votes
1 answer

Sharing Objects with other users in Django

I'm modeling a quite complex system in Django. I will post here only the relevant part of it and I will show simplified use cases diagrams to better express my ideas. I basically have 2 type of users: Seller and Customer. A Seller "acquires" a…
10
votes
3 answers

has_object_permission not called

I looked through similar questions on the same topic and I think I am following all the rules specified for has_object_permission. This is what I have in my settings. REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ …
Kishor Pawar
  • 3,386
  • 3
  • 28
  • 61
10
votes
4 answers

Django: Applying permissions in the URL dispatcher?

In my Django application, I have certain permissions which users need in order to access certain views (using django.contrib.auth). This works fine, using the @permission_required decorator on my view functions. However, some of my URLs resolve to…
kdt
  • 27,905
  • 33
  • 92
  • 139
1
2
3
28 29