Django 1.7 - makemigrations 未检测到更改 [英] Django 1.7 - makemigrations not detecting changes

查看:36
本文介绍了Django 1.7 - makemigrations 未检测到更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我似乎无法进行迁移.

As the title says, I can't seem to get migrations working.

该应用程序最初低于 1.6,所以我知道最初不会有迁移,实际上如果我运行 python manage.py migrate 我得到:

The app was originally under 1.6, so I understand that migrations won't be there initially, and indeed if I run python manage.py migrate I get:

Operations to perform:
  Synchronize unmigrated apps: myapp
  Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations to apply.

如果我对 myapp 中的任何模型进行更改,它仍然显示未迁移,正如预期的那样.

If I make a change to any models in myapp, it still says unmigrated, as expected.

但是如果我运行 python manage.py makemigrations myapp 我得到:

But if I run python manage.py makemigrations myapp I get:

No changes detected in app 'myapp'

似乎与我运行命令的内容或方式无关,它永远不会检测到应用程序有更改,也不会向应用程序添加任何迁移文件.

Doesn't seem to matter what or how I run the command, it's never detecting the app as having changes, nor is it adding any migration files to the app.

有什么方法可以强制应用程序迁移并基本上说这是我要使用的基础"或其他任何内容?还是我遗漏了什么?

Is there any way to force an app onto migrations and essentially say "This is my base to work with" or anything? Or am I missing something?

如果有帮助的话,我的数据库是 PostgreSQL 数据库.

My database is a PostgreSQL one if that helps at all.

推荐答案

如果您要从在 django 1.6 中制作的现有应用程序转换过来,那么您需要执行一个预先步骤(正如我发现的)中列出的文档:

If you're changing over from an existing app you made in django 1.6, then you need to do one pre-step (as I found out) listed in the documentation:

python manage.py makemigrations your_app_label

python manage.py makemigrations your_app_label

文档没有明确说明您需要将应用程序标签添加到命令中,因为它告诉您要做的第一件事是 python manage.py makemigrations 会失败.当您在 1.7 版中创建应用程序时,初始迁移已完成,但如果您来自 1.6 版,则不会执行.有关更多信息,请参阅文档中的向应用程序添加迁移"详情.

The documentation does not make it obvious that you need to add the app label to the command, as the first thing it tells you to do is python manage.py makemigrations which will fail. The initial migration is done when you create your app in version 1.7, but if you came from 1.6 it wouldn't have been carried out. See the 'Adding migration to apps' in the documentation for more details.

这篇关于Django 1.7 - makemigrations 未检测到更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆