0
什麼是使用django和postgresql設計多級用戶登錄系統的最佳方式。用戶的詳細信息是頭(管理員),學生,教師,工作人員等。這些不同類型的用戶詳細信息具有不同的字段,我們不能更改該字段。我們如何通過組合所有這些類型的用戶來設計用戶模型。Django多級用戶處理
class Heads(models.Model):
gid = models.IntegerField(primary_key=True)
name = models.CharField(max_length=50)
emp_code= models.CharField(max_length=50)
school = models.ForeignKey(SchoolDetails)
prdFrom = models.DateField()
contact_no=models.CharField(max_length=50)
email_id=models.CharField(max_length=50)
designation=models.CharField(max_length=50)
address =models.TextField()
def __unicode__(self):
return unicode(self.name)
class Meta:
db_table = u'heads'
verbose_name = "heads"
class Student(models.Model):
gid = models.IntegerField(primary_key=True)
name = models.CharField(max_length=50)
stud_code= models.CharField(max_length=50)
school = models.ForeignKey(SchoolDetails)
std = models.IntegerField()
division=models.CharField()
parents_email_id=models.CharField(max_length=50)
parents_contact_no=models.CharField(max_length=50)
addess =models.TextField()
def __unicode__(self):
return unicode(self.name)
class Meta:
db_table = u'students'
verbose_name = "students"
class Teacher(models.Model):
gid = models.IntegerField(primary_key=True)
name = models.CharField(max_length=50)
emp_code= models.CharField(max_length=50)
school = models.ForeignKey(SchoolDetails)
contact_no=models.CharField(max_length=50)
email_id=models.CharField(max_length=50)
address =models.TextField()
is_lead= models.CharField()
def __unicode__(self):
return unicode(self.name)
class Meta:
db_table = u'teacher'
verbose_name = "teacher"
class Staff(models.Model):
gid = models.IntegerField(primary_key=True)
name = models.CharField(max_length=50)
emp_code= models.CharField(max_length=50)
school = models.ForeignKey(SchoolDetails)
contact_no=models.CharField(max_length=50)
email_id=models.CharField(max_length=50)
address =models.TextField()
designation= models.CharField()
def __unicode__(self):
return unicode(self.name)
class Meta:
db_table = u'staff'
verbose_name = "staff"
請給出答案。
謝謝。
請給出代碼。謝謝。 – 2015-02-06 05:10:55
Dear Lego Stormtroopr,我編輯了我的問題... – Anju 2015-02-06 06:19:06