配置django项目的时候,如果表还没有创建,直接调用
PageView.objects.create(hostname=hostname)插入数据时报错:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence
解决方式:
调用脚本创建django中的表
F:\GitHub\django_algorithm>python manage.py makemigrations webAPI
Migrations for 'webAPI':
webAPI\migrations\0001_initial.py
- Create model PageView
F:\GitHub\django_algorithm>python manage.py migrate webAPI
Operations to perform:
Apply all migrations: webAPI
Running migrations:
Applying webAPI.0001_initial... OK
再次启动django访问成功