Implementing multiple roles user model in django

116 views
Skip to first unread message

Aakash Verma

unread,
Dec 23, 2020, 12:38:01 PM12/23/20
to Django users
Hi , which is the best possible way to have multiple roles user   model in django , I have tried OnetoOnefield with default user model , and then having a charField in a user model Where in choices are provided for different roles and other is trying Third party packages .
Can anyone suggest what is the best way used in Industry to implement Multiple roles in Django , (specially if roles are more than 5). Need to Implement this in Django Rest Framework .
Please suggest some good resource on it if possible 
Thanks and Regards 
Akash verma

Mike Dewhirst

unread,
Dec 23, 2020, 4:56:00 PM12/23/20
to django...@googlegroups.com
It is built into Django already. Look at django.contrib.auth ...

https://docs.djangoproject.com/en/2.2/ref/contrib/auth/#django.contrib.auth.models.Group

If you think "role" when you see "group" you have it already.

The key to success is to NEVER assign permissions to individual users.
Roles (ie groups) need to be nicely named and given exactly the
permissions required. You can then put different users into one or more
groups as necessary. Next write a few utilities such as is_editor(user)
or is_reporter(user) and so on.


> Thanks and Regards
> Akash verma
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d1b0ffb2-c148-49e1-885a-551d6ff12a07n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d1b0ffb2-c148-49e1-885a-551d6ff12a07n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.


OpenPGP_signature

Anselme Gildas Tchassem Boutchouang

unread,
Dec 23, 2020, 8:05:45 PM12/23/20
to django...@googlegroups.com
Absolutely 

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c531d0a4-1cb6-22a1-c97d-8ced458c7b1b%40dewhirst.com.au.


--
Anselme Gildas TCHASSEM BOUTCHOUANG
DevOps, Fullstack, Freelance
(+237) 696 319 191 / (+237) 698 544 992 / Email : aanseg...@yahoo.fr / LinkedIN : Profil LinkedIN / Facebook : Profil Facebook  / Whatsapp: (+237) 696 319 191
Reply all
Reply to author
Forward
0 new messages