Multiple User Roles design

42 views
Skip to first unread message

Frankline

unread,
Jun 13, 2015, 4:23:15 AM6/13/15
to django...@googlegroups.com
Hi all,

I am creating a project that will require two different user roles: An Instructor role and a Student role. Both will use a common login form. An Instructor can assign a Student to a Course. Both will have access to different parts of the system.

I wish to know the best way to model this. Currently I'm thinking of the following:

1) Use a single User model having a user_type field

2) Create Instructor and Student model that both inherit from base User model.

3) Create an Instructor and a Student group and then assign people to the correct group based on some value at the time of registration.

Is there a better way to handle this apart from the above? What are the best practices to follow in this case? Or perhaps add a UserProfile?

Regards,
Frankline

Gergely Polonkai

unread,
Jun 13, 2015, 9:25:10 AM6/13/15
to django...@googlegroups.com
Hello,

if you create groups, you don’t have to create different models for different roles (well, unless you have different data to store for Students and Instructors). Just connect the correct User object with the correct Group.

Another method is to use the Permission handling system of Django, although it is a bit more complex.

Best,
Gergely

--
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.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEAUGdXR2n0XR6gV1fMbvHxMLAJryvo7n6gJJOE615z%3DVWwpJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Filipe Ximenes

unread,
Jun 13, 2015, 10:48:20 AM6/13/15
to Django Users
You can try django-role-permissions, its an app that does exactly what you need. It's built on top of django's permissions system and requires no new models.



For more options, visit https://groups.google.com/d/optout.



--
  
Filipe Ximenes
+55 (81) 8245-9204
Vinta Software Studio
http://www.vinta.com.br
Reply all
Reply to author
Forward
0 new messages