What's the difference between staff, admin, superuser in django?

后端 未结 3 2052
萌比男神i
萌比男神i 2020-12-14 14:09

Django has superuser, staff, admin…

superuser and staff are in django.contib.auth.models.UserManager. Then there is the createsuperuser co

3条回答
  •  失恋的感觉
    2020-12-14 14:22

    Django only has one user type. Its simply User. Depending on what permissions you give the user they are able to do different things by default:

    1. Any normal user can be authenticated (that's the whole point of the user, to have a login).
    2. Any user assigned the staff flag, can login to the contributed admin app. Beyond this, they have no other special privileges.
    3. They can be set as active or not. Only active users are allowed to login.

    A superuser is just a convenience method to create a user with all permissions. They are just normal users given staff and all permissions by default.

    There is also ADMINS and MANAGERS settings.

    These are used for notifications, when the site is running in production (ie, when DEBUG is False).

    Admins are notified of any errors that generate a traceback. They are emailed the traceback and information about the request. Managers are emailed when someone requests a link that doesn't exist (basically, when a 404 is raised).

提交回复
热议问题