G
G
Gennady2018-06-07 18:16:57
Django
Gennady, 2018-06-07 18:16:57

Is it possible to differentiate permissions in the Django admin panel?

Hi all!
There was a need to automate some things at work, the choice fell on python + Django.
There are several models, respectively, records are stored in the database.
Tell me, is it possible in the Django admin panel to give access to records to a user by criteria? For example, in my table with records there is a column with the name of the department. Is it possible to give a user the right to view/edit only the records of his department?
If so, please point me in the right direction. I understand that this logic can be written in app \ admin.py?
Or do you still have to write your authorization + logic in your views?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-06-07
@genana40

In the admin class, for each model, you can override the get_queryset , has_add_permission , has_change_permission and has_delete_permission methods , in which it is easy to define the logic of flexible separation of rights to view, add, change and delete records.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question