1

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

Ludisposed
  • 1,709
  • 4
  • 18
  • 38
  • 1
    this question has been asked couple times. What have you tried? where is your code? next time google first, maybe you find something [link](https://www.vinta.com.br/blog/2016/controlling-access-a-django-permission-apps-comparison/) – hansTheFranz May 29 '17 at 10:31

1 Answers1

2

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?