[Django]-What is the proper way to address permissions?

4👍

Permission (which lives in django.contrib.auth.models) is a database object. You’ll be able to see all of them with Permission.objects.all(). They are created automatically by a post-sync signal for each model (and as the docs mention, you can also define your own).

To assign the permissions to a User, you will first have to get the Permission objects (using Permission.objects.get(*args)), and then you can add it to the User with User.user_permissions.add(permission) as you mentioned.

Alternatively, and the easier way if you can do this, is just to use the Django admin site. In the detail page for each user, there is a section relating to permissions. I’m guessing you aren’t using these permissions outside of the admin, so that’s the only area they will affect. If you want all of your users to have all permissions, you can make them superusers by setting the is_superuser flag on each User to True.

Leave a comment