Search code examples
pythondjangodjango-modelsdjango-users

Grouping standard user models in django


I have a webapp and all of my users are divided into 2 groups: Teachers and Students. How can I create groups and assign users to groups in order to identify which group a user belongs to in Django? Additionally, can I create views that only certain groups can access?


Solution

  • Here are some resources below for you to take a look at:

    You can create a two groups, Teacher and Student. You will then assign permissions to these groups, not the individual users. Therefore, if you part of the teacher group, you get all teacher permissions.

    Django groups docs

    Medium article for groups

    Creating groups - StackOverflow