class Account(models.Model): user_name=models.CharField(u"用户名",max_length=80) password=models.CharField(u"密码",max_length=255) reg_data=models.DateField() def __unicode__(self): return "Account : %s"%self.user_name class Contact(models.Model): account=models.OneToOneField(Account,on_delete=models.CASCADE,primary_key=True) zip_code=models.CharField(max_length=10) address=models.CharField(max_length=80) mobile=models.CharField(max_length=20) def __unicode__(self): return "%s , %s"%(self.account.user_name,self.mobile)
DjangoORM的一对一数据库设计
猜你喜欢
转载自blog.csdn.net/douyunqian668/article/details/80235729
今日推荐
周排行