Nithin sai kumar
Nithin sai kumar

Reputation: 41

needed django users and subusers with limited permissions

I am a beginner of django.

I am trying to create a user below the admin: Let's call him user1 and below this user there will be other users: user2,user3,user4,..user50.

So my question is:

An Admin can access everything, but users should access only some permissions. How can I implement this? So that each user has it's own permissions.

User1 has permissions 1,2,3

User2 has permisison 2

Can anyone help me? Thanks in advance

Upvotes: 1

Views: 1024

Answers (1)

Hakan Yalcinkaya
Hakan Yalcinkaya

Reputation: 152

You will use Django Permissions.

https://docs.djangoproject.com/en/1.11/topics/auth/default/#topic-authorization

myuser.groups.set([group_list])
myuser.groups.add(group, group, ...)
myuser.groups.remove(group, group, ...)
myuser.groups.clear()
myuser.user_permissions.set([permission_list])
myuser.user_permissions.add(permission, permission, ...)
myuser.user_permissions.remove(permission, permission, ...)
myuser.user_permissions.clear()

and you will use included decorators or you will create custom decorators.

https://docs.djangoproject.com/en/1.11/ref/contrib/auth/#django.contrib.auth.models.User.is_staff

Custom Decorator: How to write a custom decorator in django?

Upvotes: 2

Related Questions