Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django user hierarchy

I'm to make a web app that will implement something like user hierarchy. I would like to do it like this: 1. Superuser makes users (with some permissions), who can also add users (only with permissions which they own). This users can also add users, and so on. No one should be able to edit users who have more permissions.

The thing is that I want to make Django Admin Panel avaliable for all of these users. Is it even possible to make such thing? I've searched the web and didn't find solution. Thanks for advice.

like image 845
kaapa Avatar asked Nov 11 '11 14:11

kaapa


1 Answers

You'll need to create your own views for adding users if you want to control the created users' permissions. On the Django admin site, any user that can create users can create superusers.

From the Django docs on creating users:

If you want your own user account to be able to create users using the Django admin site, you'll need to give yourself permission to add users and change users (i.e., the "Add user" and "Change user" permissions). If your account has permission to add users but not to change them, you won't be able to add users. Why? Because if you have permission to add users, you have the power to create superusers, which can then, in turn, change other users. So Django requires add and change permissions as a slight security measure.

like image 103
Alasdair Avatar answered Sep 21 '22 21:09

Alasdair