Django 1.7 - “无需迁移"在 makemigrations 之后运行 migrate 时 [英] Django 1.7 - "No migrations to apply" when run migrate after makemigrations

查看:29
本文介绍了Django 1.7 - “无需迁移"在 makemigrations 之后运行 migrate 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 Django1.7 与 Mezzanine 一起使用.我创建了存储在单独的应用程序配置文件"中的简单配置文件(根据夹层文档):

I use Django1.7 with Mezzanine. I create simple profile (according to Mezzanine documentation) stored in separate app "profiles":

class RoadmapProfile(models.Model):
    user = models.OneToOneField("auth.User")
    fullname = models.CharField(max_length=100, verbose_name="Full name")

创建迁移返回:

  Migrations for 'profiles':
      0001_initial.py:
        - Create model RoadmapProfile

当我运行迁移配置文件"时:

When I run "migrate profiles":

Operations to perform:
  Apply all migrations: profiles
Running migrations:
  No migrations to apply.

问题是,当我尝试打开与 mezzanine.accounts 相关的任何页面(例如更新帐户)时,它会崩溃:

The issue is, when I try to open any page related to mezzanine.accounts (for example update account), it crashes with:

OperationalError at /accounts/update/

no such column: profiles_roadmapprofile.fullname

我做错了什么?

推荐答案

听起来您的初始迁移是伪造的,因为该表已经存在(可能具有过时的架构):

Sounds like your initial migration was faked because the table already existed (probably with an outdated schema):

https://docs.djangoproject.com/en/1.8/topics/migrations/#adding-migrations-to-apps

"这将为您的应用程序进行新的初始迁移.现在,当你运行 migrate,Django 会检测到你有一个初始迁移并且它要创建的表已经存在,并将标记已应用迁移."

"This will make a new initial migration for your app. Now, when you run migrate, Django will detect that you have an initial migration and that the tables it wants to create already exist, and will mark the migration as already applied."

否则你会得到一个没有此类表的错误:)

Otherwise you would get an no-such-table error :)

您是否清理了应用迁移表?这也是非应用迁移的常见原因.

Did you clean up the applied-migrations table? That's also a common cause for non-applied migrations.

这篇关于Django 1.7 - “无需迁移"在 makemigrations 之后运行 migrate 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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