[英]PythonAnywhere: django.db.utils.OperationalError: no such table:
I am deploying
a project on PythonAnywhere
.我正在
PythonAnywhere
上deploying
一个项目。 I am using sqlite
database.我正在使用
sqlite
数据库。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mydatabase.db',
}
}
When makemigrations
starts, the file mydatabase.db
is created (its size is 0 bytes) in root of the project, but I get an error - django.db.utils.OperationalError: no such table: ...
当
makemigrations
启动时,在项目的根目录中创建文件mydatabase.db
(其大小为 0 字节),但出现错误 - django.db.utils.OperationalError: no such table: ...
The error was due to my carelessness.错误是由于我的粗心造成的。
In django, views.py
is performed before migrations
.在 django 中,
views.py
在migrations
之前执行。 There was a line that ran a database query
.有一行运行
database query
。 Since the database
was empty on the server, and the script was already executing a request to it, it is obvious that during the migrations
I received this error.由于服务器上的
database
是空的,并且脚本已经在执行对它的请求,很明显在migrations
期间我收到了这个错误。
It was enough just to delete / comment out the database request.只需删除/注释掉数据库请求就足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.