标签:efi comm asc init 数据库 man name tool OLE
D:\TOOL\PycharmProjects\python3\BS\h2>python manage.py makemigrations**
在django2.0后,定义外键和一对一关系的时候需要加on_delete选项,此参数为了避免两个表里的数据不一致问题,不然会报错:
TypeError: init() missing 1 required positional argument: ‘on_delete‘
解决方案:
class BookInfo(models.Model):
btitle = models.CharField(max_length=20)
bpub_date = models.DateTimeField()
class HeroInfo(models.Model):
hname = models.CharField(max_length=20)
hgender = models.BooleanField()
hcontent = models.CharField(max_length=100)
hbook = models.ForeignKey(‘BookInfo‘, on_delete=models.CASCADE)
https://www.cnblogs.com/phyger/p/8035253.html
标签:efi comm asc init 数据库 man name tool OLE
原文地址:http://blog.51cto.com/357712148/2330983