Django 1.7 - makemigrations没有检测到变化 [英] Django 1.7 - makemigrations not detecting changes

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

问题描述

如标题所示,我似乎无法让迁移工作。



应用程序原本低于1.6,所以我明白迁移不会在那里最初,确实如果我运行 python manage.py migrate 我得到:

 执行操作:
同步未迁移的应用程序:myapp
应用所有迁移:admin,contenttypes,auth,sessions
同步不需要迁移的应用程序:
创建表...
安装自定义SQL ...
安装索引...
运行迁移:
不应用迁移。

如果我对 myapp ,它仍然表示没有移民,如预期的那样。



但是,如果我运行 python manage.py makemigrations myapp 获取:

 应用程序'myapp'中没有检测到变化

似乎不管什么或如何运行命令,它从来没有检测到应用程序有更改,也没有添加任何迁移文件到应用程序。



有没有办法强制应用程序迁移,基本上说这是我的工作基础或任何东西?或者我错过了什么?



我的数据库是一个PostgreSQL,如果这有帮助的话。

解决方案

好吧,看起来我错过了一个明显的一步,但发布这个,以防其他人都一样。



升级到1.7时,我的模型变得不受管理( managed = False ) - 我把它们当作 True ,但似乎已被恢复。 >

删除该行(默认为True),然后运行 makemigrations 立即进行迁移模块,现在它正在运行。 makemigrations 不适用于非托管表(这在后见之明是明显的)


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

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.

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

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?

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

解决方案

Ok, looks like I missed an obvious step, but posting this in case anyone else does the same.

When upgrading to 1.7, my models became unmanaged (managed = False) - I had them as True before but seems it got reverted.

Removing that line (To default to True) and then running makemigrations immediately made a migration module and now it's working. makemigrations will not work on unmanaged tables (Which is obvious in hindsight)

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

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