D
D
Denis Michurin2019-06-09 14:02:06
Django
Denis Michurin, 2019-06-09 14:02:06

How to implement permissions for individual model objects?

There is an Action model, it will store actions for the user. These actions need to be limited, so that some users would not have access to some of the actions.
How to implement this?
Google didn't answer

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FulTupFul, 2019-06-09
@denistu10

class Action:
    class Meta:
        permissions = (("can_something", "что-то может"),)

Save to database
python manage.py makemigrations <app>
python manage.py migrate

We check the rights in the right place
action.has_perm("can_something")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question