python-Django常见错误

我爱海鲸 2021-06-12 22:50:30 python

简介python包的安装

安装富文本编辑器:

pip install django-ckeditor

安装全文搜索引擎容器:

pip install django-haystack

安装全文搜索引擎:

pip install whoosh

安装中文分词:

pip install jieba

安装mysqlclient

pip install mysqlclient==2.0.1


python manage.py makemigrations post 创建迁移文件 出现的错误:

undefined

在setting.py中加入即可解决

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

undefined

python manage.py migrate 创建到数据库时会出现:

undefined

查看python manage.py sqlmigrate post 0001 迁移文件中的sql语句:

undefined

会存在问题,在网上找到的原因是,mysql数据库版本的问题,在5.5以后不会存在这个问题,这里的解决方案:

 python3Libsite-packagesdjangodbackendsmysqlase.py 在django包路径下  修改:

'DateTimeField': 'datetime(6)', 为: 'DateTimeField': 'datetime',

创建迁移文件时,生成数据库表应当注意:

class Meta:

    # managed = False   //这里要设置为False或者不写,不然不会生成数据的表

    db_table = 'movie'

如图:

undefined

你好:我的2025