B
B
Bjornie2018-01-29 23:34:02
Django
Bjornie, 2018-01-29 23:34:02

What is the correct way to control access to functionality in Django?

I am writing a project in which a registered user has 2 roles (client and executor). Each role has its own tasks, so many sections and links may differ.
Partially, I already understood where I can create conditions directly in the template (for example, user.is_authenticated), or check the role in the view and, based on this, issue the appropriate template (so as not to fence anything in it). On the guest I use a decorator.
With the complication of the system, I understand that it will not be enough just to substitute the desired template or hide the link, you need to control everything on the backend (for example, do not allow the CONTRACTOR to view the CREATE ORDER page, because this is not his role.
Question: how best to do this, what is the best practice used in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Astrohas, 2018-01-30
@Astrohas

Use standard groups + Decorators (mixins) for views

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question