Wednesday, December 23, 2020

Re: Implementing multiple roles user model in django

On 24/12/2020 4:38 am, Aakash Verma wrote:
> 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

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+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@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.


--
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+unsubscribe@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.

No comments:

Post a Comment