试用Djiango的时候发现执行mange.py makemigrations 和 migrate是会报错,少位置参数on_delete,查了一下是因为指定外键的方式不对,改一下就OK了. 代码如下: from django.db import models # Create your models here. class BookInfo(models.Model): """model of book infomation""" # 书的标题…
python: 3.6.4 django: 2.0 models.py 代码如下 # coding: utf-8 from django.db import models from django.contrib.auth.models import User # Create your models here. class Category(models.Model): name = models.CharField(max_length=100) class Tag(models.Model)…
from django.db import models # Create your models here. class Category(models.Model): caption = models.CharField(max_length=) class ArticleType(models.Model): caption = models.CharField(max_length=) class Article(models.Model): title = models.CharFie…
最近在使用Python的Django框架开发web站点,通过models.py文件建表后,执行数据库迁移(命令行:mange.py makemigrations)时报错,下面是查看官方文档后找到的解决方案. 官方文档:Model field reference 报错内容: class Guest(models.Model): File "C:\Users\dell\guest\sign\models.py", line 18, in Guest event = models.Forei…