白洁

day52 Django-ORM多表增删改查

谁说我不能喝 提交于 2019-12-05 14:51:10
day52 Django-ORM多表增删改查 创建关系字段 class Author(models.Model): name=models.CharField(max_length=32) age=models.IntegerField() ad=models.OneToOneField(to="AuthorDetail",to_field="id",on_delete=models.CASCADE) # to_field="id" 可以不写,默认找主键 # to="AuthorDetail", to=可以不用写 # models.SET_NULL 置空 # on_delete=models.CASCADE 默认是级联删除,想做级联更新,直接去数据库修改表结构 class AuthorDetail(models.Model): birthday=models.DateField() telephone=models.CharField(max_length=16) addr=models.CharField(max_length=64) class Publish(models.Model): name=models.CharField(max_length=32) city=models.CharField(max_length=32) class Book(models

day52 Django-ORM多表增删改查

本秂侑毒 提交于 2019-11-27 01:33:47
day52 Django-ORM多表增删改查 创建关系字段 class Author ( models . Model ) : name = models . CharField ( max_length = 32 ) age = models . IntegerField ( ) ad = models . OneToOneField ( to = "AuthorDetail" , to_field = "id" , on_delete = models . CASCADE ) # to_field="id" 可以不写,默认找主键 # to="AuthorDetail", to=可以不用写 # models.SET_NULL 置空 # on_delete=models.CASCADE 默认是级联删除,想做级联更新,直接去数据库修改表结构 class AuthorDetail ( models . Model ) : birthday = models . DateField ( ) telephone = models . CharField ( max_length = 16 ) addr = models . CharField ( max_length = 64 ) class Publish ( models . Model ) : name = models .

day52 Django-ORM多表增删改查

情到浓时终转凉″ 提交于 2019-11-25 18:48:22
day52 Django-ORM多表增删改查 创建关系字段 class Author(models.Model): name=models.CharField(max_length=32) age=models.IntegerField() ad=models.OneToOneField(to="AuthorDetail",to_field="id",on_delete=models.CASCADE) # to_field="id" 可以不写,默认找主键 # to="AuthorDetail", to=可以不用写 # models.SET_NULL 置空 # on_delete=models.CASCADE 默认是级联删除,想做级联更新,直接去数据库修改表结构 class AuthorDetail(models.Model): birthday=models.DateField() telephone=models.CharField(max_length=16) addr=models.CharField(max_length=64) class Publish(models.Model): name=models.CharField(max_length=32) city=models.CharField(max_length=32) class Book(models