[Fixed]-How to have multiple types of users in separated tables?

1👍

You can implement related_name attributes something similar to this:

from django.contrib.auth.models import User

class ClassRoom(models.Model):
    # One classroom one teacher
    teacher = models.ForeignKey(User, related_name="teacher")
    # One classroom many students
    student = models.ManytoManyField(User, blank=True, null=True,
                                     related_name="students")
    .....

Also refer to these links for more info:

Django teacher students easy solution. Use separate tables, or permissions and groups? How? Other ideas?

Django model with Foreign Key and ManyToMany relations to same model

Two sets of users (teacher and student) in Django authentication

Leave a comment