class doctorMaster(models.Model):
doctorID = models.AutoField(primary_key=True)
doctorName = models.CharField(max_length=100,null=False)
doctorDesignation = models.CharField(max_length=100,null=True)
doctorSpecialization = models.CharField(max_length=100,null=True)
UpdatedOn = models.DateTimeField(default=timezone.now, null=True)
def __unicode__(self):
return str(self.doctorID)
class SMSlookup(models.Model):
recordID = models.AutoField(primary_key=True)
doctorID = models.OneToOneField(doctorMaster,on_delete=models.CASCADE,to_field='doctorID')
doctorName = models.CharField(max_length=100,null=False)
SMSContact = models.IntegerField (null = False)
UpdatedOn = models.DateTimeField(default=timezone.now, null=True)
def __unicode__(self):
return str(self.doctorID)
我需要能够在第二个模型中使用其同名来访问第一个模型的doctorID。
应该如何定义doctorID?