Django|Django 单元测试报错没有创建数据表
报错描述
【Django|Django 单元测试报错没有创建数据表】报错如下
> python manage.py test tweets
..............
File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py", line 73, in execute
return self.cursor.execute(query, args)
File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\cursors.py", line 206, in execute
res = self._query(query)
File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\cursors.py", line 319, in _query
db.query(q)
File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\connections.py", line 259, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'test_d_twitter_db.tweets_tweet' doesn't exist")
PS C:\Users\17293\Desktop\Coder\Python\Django\twitter> python .\manage.py makemigrations
数据表是单元测试自己创建的,是不是手动创建的
所以这个报错一开始让我摸不着头脑
解决方案 执行如下命令
python manage.py makemigrations
在执行单元测试的命令就好了
python manage.py test tweets
不需要执行
python manage.py migratie
推荐阅读
- django-前后端交互
- 女生该不该用小号测试男朋友()
- BNC公链|BNC公链 | Eth2.0测试网Topaz已质押超100万枚ETH
- 我的软件测试开发工程师书单
- 性能测试中QPS和TPS的区别
- 20180322【w4复盘日志】
- 如何在手机上查看测试vue-cli构建的项目
- 工作好忙
- 没有复用的cell|没有复用的cell 单元格的写法
- django2.2|django2.2 一般项目步骤(初步)