【问题标题】:No changes detected for makemigrations未检测到针对 makemigrations 的更改
【发布时间】:2020-11-25 05:27:14
【问题描述】:

我是 Django 新手。我想使用模型创建表。 我已尝试点击此链接:https://docs.djangoproject.com/en/3.0/topics/db/models/

我已经注册了应用程序并提供了数据库的连接详细信息。

但是当我尝试运行 makemigrations 和 migrate 时,它​​并没有识别出更改。 python manage.py makemigrations 未检测到更改

python manage.py 迁移 要执行的操作: 应用所有迁移:admin、auth、contenttypes、sessions 运行迁移: 没有要应用的迁移。

如有任何帮助,将不胜感激。

【问题讨论】:

  • 你有没有在installed_app列表的settings.py中指定应用名称

标签: python django postgresql orm


【解决方案1】:

对于没有任何迁移的新应用,您必须首先创建一个初始迁移文件。这可以通过将应用名称传递给 makemigrations

来完成
python manage.py makemigrations app

Here is the relevant section of the docs

要将迁移添加到没有迁移目录的应用,请使用应用的 app_label 运行 makemigrations

【讨论】:

    猜你喜欢
    • 2016-07-09
    • 1970-01-01
    • 2021-05-09
    • 2014-09-14
    • 2019-11-01
    • 2021-02-07
    • 2016-06-19
    相关资源
    最近更新 更多