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.

350 questions
89
votes
7 answers

How can I use Django permissions without defining a content type or model?

I'd like to use a permissions based system to restrict certain actions within my Django application. These actions need not be related to a particular model (e.g. access to sections in the application, searching...), so I can't use the stock…
Chewie
  • 6,555
  • 3
  • 28
  • 36
83
votes
1 answer

How do I use Django groups and permissions?

I understand the basic user stuff. I know authentication, login, creating accounts, etc. But now I want to work on groups and permissions. Where is the documentation for django groups/permissions? This is not it:…
TIMEX
  • 217,272
  • 324
  • 727
  • 1,038
71
votes
5 answers

Adding new custom permissions in Django

I am using custom permissions in my Django models like this: class T21Turma(models.Model): class Meta: permissions = (("can_view_boletim", "Can view boletim"), ("can_view_mensalidades", "Can view…
gerdemb
  • 10,547
  • 15
  • 62
  • 71
51
votes
9 answers

How to check (in template) if user belongs to a group

How to check in template whether user belongs to some group? It is possible in a view which is generating the template but what if I want to check this in base.html which is an extending template (it does not have it's own view function)? All of my…
Milano
  • 13,773
  • 29
  • 96
  • 240
44
votes
5 answers

Django REST Framework viewset per-action permissions

Is there a best practice to assign a different permission to each action of a given APIView or ViewSet? Let's suppose I defined some permissions classes such as 'IsAdmin', 'IsRole1', 'IsRole2', ..., and I want to grant different permissions to the…
lWhitmore
  • 463
  • 1
  • 4
  • 7
36
votes
2 answers

django-object-permissions Vs django-guardian Vs django-authority

I've found 3 row-level permission solutions for Django 1.2+ django-object-permissions django-guardian django-authority Could someone tell if there is any recommended more than the others, what are their main differences, etc.?
Akasha
  • 2,138
  • 1
  • 25
  • 43
35
votes
1 answer

User groups and permissions

I need to implement user rights for user groups (pretty similar to facebook groups). For example, each group can have members with rights like: can_post, can_delete, can_ban, etc. Of course, one user can be a member of many groups and group can have…
duke_nukem
  • 637
  • 2
  • 8
  • 16
31
votes
6 answers

How can I MODIFY django to create "view" permission?

I've recently started using django to administer a large existing application that was grown organically over the years using twisted.web. I started experimenting with django and it's automatic admin interface and I've been very pleased with the…
Great Turtle
  • 3,215
  • 7
  • 29
  • 36
29
votes
1 answer

Add a custom permission to a User

I'd like to be able to give some existing Users a custom permission which I will require for accessing a view. I think I need to add the new permission to the Postgres table auth_permission, but I suspect there is a higher-level way to do this. …
Mitch
  • 2,078
  • 6
  • 27
  • 45
28
votes
1 answer

Django user get_all_permissions() is empty while user_permissions is set

I added some permissions to a user via the admin interface. From some reason all the perm functions fail, e.g >>> user.get_all_permissions() set([]) But accessing the table directly, works: >>> user.user_permissions.all() (list of permissions as…
Boris
  • 3,054
  • 5
  • 32
  • 44
24
votes
5 answers

Django - user permissions to certain views?

From the admin I see that you can allocate permissions to a user or a user group to :allow add, change or delete data from a model. That is great, but I also need to allow a user or a user group to access or not a group of views. I have certain…
avatar
  • 10,735
  • 15
  • 58
  • 80
19
votes
4 answers

How to add custom permission to the User model in django?

in django by default when syncdb is run with django.contrib.auth installed, it creates default permissions on each model... like foo.can_change , foo.can_delete and foo.can_add. To add custom permissions to models one can add class Meta: under the…
gsin
  • 373
  • 2
  • 3
  • 8
18
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,104
  • 2
  • 12
  • 29
18
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
  • 9,085
  • 17
  • 56
  • 81
17
votes
1 answer

How to check current user's permissions from a Group in Django?

I have a group EuropartsBuyer and model named Product. The following code adds a permission to the Product model. class Meta: permissions = ( ("can_add_cost_price", "Can add cost price"), ) In one of my views I have the…
MiniGunnR
  • 4,590
  • 5
  • 33
  • 54
1
2 3
23 24