Reputation: 97
Is it possible to create two different profiles and have them both extend Django User Model. I am trying to create a student profile and a teacher profile, how should I go about doing this? My student profile has attributes such as courses taken, but the teacher should not have access to taking courses, only create them.
Upvotes: 2
Views: 818
Reputation: 665
You can inherit the django builtin User
Models class into any number of models.
from django.contrib.auth.models User
class Course(models.Model):
name = models.CharField(-----)
class Teacher(User):
pass
class Course(models.Model):
teacher = models.ForeignKey(Teacher)
class Student(User):
courses = models.ManyToManyField(Course)
Upvotes: 1
Reputation: 383
You can create multiple models inherit User
model.
class Teacher(User):
pass
class Course(models.Model):
teacher = models.ForeignKey(Teacher)
class Student(User):
courses = models.ManyToManyField(Course)
Upvotes: 3