2π
β
It is better to handle it with a field (not with 2 different models) for example you can have something like this:
class User(models.Model) :
# NEW
ROLES = (('student', 'Student'), ('teacher', 'Teacher'))
role = models.CharField(
max_length=20,
choices=ROLES,
default='student'
)
national_id = models.CharField(
max_length=50,
unique=True,
)
name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
phone_number = models.CharField(max_length=50)
Also, you can use the Django permission model more detail
0π
Django has Roles and Groups to categorise users. What is allowed and forbidden is controlled by Permissions. Every User, Role and Group can have different model-specific and view-specific Permissions. The system is quite complex and allows for many different setups. Iβd suggest you chek an overview such as this one.
π€Jura Brazdil
Source:stackexchange.com