【发布时间】:2018-10-05 21:00:07
【问题描述】:
我正在尝试使用自己的数据库启动夹层项目,但是当我创建数据库并在启动新项目后迁移时,数据库仍然为空。这就是我所做的:
1) 在 PGADMIN 4 中,我创建了一个名为“mydatabase”的新数据库,用户为“myuser”,密码为“mypassword”
2) 我开始一个新的夹层项目:
mezzanine-project testproject
3) 我将 settings.py 中的数据库更改为:
DATABASES = {
"default": {
# Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
"ENGINE": "django.db.backends.postgresql_psycopg2",
# DB name or path to database file if using sqlite3.
"NAME": "mydatabase",
# Not used with sqlite3.
"USER": "myuser",
# Not used with sqlite3.
"PASSWORD": "mypassword",
# Set to empty string for localhost. Not used with sqlite3.
"HOST": "localhost",
# Set to empty string for default. Not used with sqlite3.
"PORT": "5432",
}
}
4) 最后,我运行:
python manage.py migrate
一切运行良好——但我在 PGADMIN 4 中创建的数据库仍然是空的(没有新表),即使在刷新和重新启动之后也是如此。
那么,这个数据库是在哪里创建的?我将数据库指定为 postgres 数据库,而我的计算机上没有任何其他 postgres 实例?如何让表填充到我的 mydatabase 数据库中?
提前致谢!
【问题讨论】:
标签: django python-3.x mezzanine postgresql-10