Answer the question
In order to leave comments, you need to log in
What is the best way to use permission in django?
I have two pages, one I want to show only to the User model class, the second one only to the Partner model class. What is the best way to specify this in models and in views? If it's not difficult, write what should be in Views. And how it will look if you give rights not to a class, but only to a certain user.
Answer the question
In order to leave comments, you need to log in
https://docs.djangoproject.com/en/2.1/topics/class...
Everything is in the documentation.
I would not make two User and Partner models, I would limit myself to one User. Django has a fairly well thought out mechanism for assigning permissions. So you create the Partners group and assign rights there, add partners to this group. If you use CBV, then there is a special mixin that adds an attribute and there you can specify the rights that the user should have.
You will also find the django-rules package useful.
If you have questions or need links to details, then write in the comments.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question