模型.py
class userdetails(models.Model):
userid=models.IntegerField(unique=True)
firstname=models.CharField(max_length=100,null=False,blank=False)
lastname=models.CharField(max_length=100,null=True,blank=True)
emailid=models.CharField(max_length=500,null=False,blank=False)
def __unicode__(self):
return self.firstname
class studdetails(models.Model):
total=models.CharField(max_length=500)
fkid=models.IntegerField()
def __unicode__(self):
return self.userdetails.firstname
我试图获取 studdetails.fkid=userdetails.userid 的 userdetails 表的名字字段。任何人都可以帮忙吗?请!