I'm a newbie to Django. I am working on an Application where data are to be shown to users based on their roles. Example User A Should only see the data created by A. Similarly User B should See only his data. Finally, there is a superuser who can see all data. What is the best way in Django to implement this?. Currently, I am trying with Django ORM Managers.
Asked
Active
Viewed 195 times
1
-
Django has a permission system. You can use the default User model or your own subclass to represent people, and give them various permissions, creating your own if needed, though your case is probably covered by the default ones. You can read about it [here](https://docs.djangoproject.com/en/3.2/topics/auth/default) – MegaBluejay Oct 19 '21 at 16:40
-
1Please provide enough code so others can better understand or reproduce the problem. – Community Oct 19 '21 at 16:44
-
There are some packages that can do this job like `django-guardian`. Nevertheless, you can create groups and add parameters for each user to be accepted into this groups. Ex: all user with is_engineer user will only have access to engineer users. However, RBAC have way more details than this. – Elias Prado Oct 20 '21 at 04:29