【发布时间】:2015-11-09 21:01:37
【问题描述】:
我在 Django 1.8 上有一个带有初始数据夹具的应用程序。当我运行manage.py migrate 时,我得到以下输出:
Operations to perform:
Synchronize unmigrated apps: food, locations, messages, staticfiles, core
Apply all migrations: auth, sessions, admin, contenttypes
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
/home/myuser/venv/lib/python3.4/site-packages/django/core/management/commands/loaddata.py:229: RemovedInDjango19Warning: initial_data fixtures are deprecated. Use data migrations instead.
RemovedInDjango19Warning
Installed 87 object(s) from 1 fixture(s)
Running migrations:
No migrations to apply.
所以看起来夹具已经安装,但不是真的 - 当我登录到我的 postgres 用户并运行 psql 和 \dt 时,没有列出任何表(我确保首先使用 @ 连接到数据库987654325@)!尝试在浏览器中查看应用程序时,我得到:ProgrammingError at / relation "locations_openinghours" does not exist。 (这恰好是应用尝试访问的第一个表)。
【问题讨论】:
-
在运行
python manage.py migrate之前,您是否尝试过运行python manage.py makemigrations? -
是的,我以前这样做过——当我再次这样做时,我得到
No changes detected。我的项目中的任何地方都没有名为迁移的文件夹(没有创建任何文件夹)。 -
您可以添加更多信息吗?比如向我们展示您的模型的代码 sn-p 以及您的设置的
INSTALLED_APPS部分? -
是的,我现在已经做到了。谢谢!
标签: python django database postgresql