-
Notifications
You must be signed in to change notification settings - Fork 314
Open
Description
运行环境: Ubuntu18.04,按照README.md
中的步骤,尝试在本地运行,在第四步迁移数据库,执行
pipenv run python manage.py migrate
命令时发生报错,错误信息是:
django.db.utils.OperationalError: unable to open database file
并且根目录下并没有像以往一样生成db.sqlite3
文件,于是去查看
HelloDjango-blog-tutorial/blogproject/settings
文件夹下的common.py
文件,发现DATABASES
设置如下:
DATABASES = {
'default': {
'ENGINE' 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'database', 'db.sqlite3'),
}
根据django官方文档:
NAME¶
默认值:(''空字符串)
要使用的数据库的名称。对于SQLite,它是数据库文件的完整路径。指定路径时,即使在Windows(例如C:/homes/user/mysite/sqlite3.db)上,也始终使用正斜杠。
'NAME'
指定了db.sqlite3
文件的完整路径,但是克隆下来的项目根目录中并没有database
这个文件夹,因此导致报错unable to open database file
,在项目根目录下手动新建database
文件夹后,问题解决。
Lounode, suzhi82, smithCoderLeo, 521xueweihan and xzmeng
Metadata
Metadata
Assignees
Labels
No labels