【问题标题】:django oscar migrations not migrating, other app migratesdjango oscar 迁移未迁移,其他应用程序迁移
【发布时间】:2017-11-04 15:21:58
【问题描述】:

我一直很困惑,我一遍又一遍地阅读文档。我的模型没有迁移。我的提示是No changes detected in app "catalogue",但我确实进行了更改。我似乎无法弄清楚我做错了什么。有时它有效,我不知道为什么。我记下它并重复它,它不起作用。任何建议或想法表示赞赏。谢谢!!!

subapp1 是使用 oscar 的商店应用,subapp2 是另一个应用

我运行 python manage.py makemigrations catalogue 然后 python managepy migrate catalogue 我也尝试在 subapp1 中迁移。结果是一样的。

app/settings.py

INSTALLED_APP = [...] + + get_core_apps(['subapp1.catalogue'])

我还按照文档中的说明分叉了迁移文件夹。我也试过没有它。 (是的,我有我的__init.py__ 文件。

app/subapp1/catalogue/models.py

from django.db import models
from django.utils.translation import ugettext_lazy as _

from subapp2 import models as subapp2_models

from oscar.apps.catalogue.abstract_models import AbstractProductImage
from oscar.core.loading import get_model

product = get_model('catalogue','Product')
links = subapp2_models.links

class ProductImage(AbstractProductImage):
    links= models.ForeignKey(links)
    product = models.ForeignKey('catalogue.Product', related_name='photo_links', verbose_name=_("Product"))

    class Meta:
        app_label = 'catalogue'
        verbose_name = _('link image')

    def __str__(self):
        return u"Image of '%s'" % self.product

from oscar.apps.catalogue.models import *

【问题讨论】:

    标签: python django django-oscar


    【解决方案1】:

    我以前遇到过类似的事情。 Django 迁移可能存在错误,具体取决于您使用的版本。我相信我在使用 1.8 或 1.9 时遇到了问题。

    我解决它的方法是通过找到 migrations 目录并删除其中的文件来从相关应用程序中删除迁移。然后,我会运行make migrations,然后它会成功获取更改。

    再一次,我不确定是 Django 本身的错误还是 Oscar 的错误

    【讨论】:

      猜你喜欢
      • 2016-04-14
      • 2015-06-17
      • 1970-01-01
      • 2020-10-14
      • 1970-01-01
      • 2018-02-25
      • 1970-01-01
      • 2017-06-26
      • 2014-08-21
      相关资源
      最近更新 更多