【问题标题】:Django South DatabaseError: App inside app - Table doesn't existDjango South DatabaseError:应用程序内的应用程序 - 表不存在
【发布时间】:2014-03-13 15:10:25
【问题描述】:

在受到 django-oscar 的启发后,我尝试在其主应用程序中放置一个 cmsplugin。但是,在执行schemamigration --initial 之后,我无法在 Django CMS 中使用该插件。

DatabaseError: (1146, "Table 'devel_test.cmsplugin_galleries_gallerycontainer_galleries' doesn't exist")

应用树

  • 图库
    • 应用程序
      • cmsplugin_galleries
        • 迁移
        • cms_plugins.py
        • 初始化.py
        • models.py
      • 初始化.py
    • 迁移
    • 静态
    • 模板
    • admin.py
    • 初始化.py
    • models.py
    • views.py

画廊模型

class Gallery(models.Model):
    title = models.CharField(_(u'title'), max_length=200)
    description = models.TextField(_(u'description'), blank=True)
    image_folder = FilerFolderField(verbose_name=_(u'image folder'))
    is_video = models.BooleanField(_(u'is video content'), default=False)
    snippet = models.TextField(_(u'video snippet'))

    class Meta:
        verbose_name = _(u'Gallery')
        verbose_name_plural = _(u'Galleries')

class GalleryImage(models.Model):
    gallery = models.ForeignKey(Gallery, verbose_name=_(u'gallery'))
    title = models.CharField(_(u'title'), max_length=200, blank=True)
    src = FilerImageField(verbose_name=_(u'image'))

Cmsplugin_galleries 模型

class GalleryContainer(CMSPlugin):
    title = models.CharField(_(u'title'), max_length=200)
    galleries = models.ManyToManyField(Gallery, verbose_name=_(u'galleries'))

    def __unicode__(self):
        return u'%s' % self.title

既然我可以使用syncdb --all 正确运行它,我做错了什么?

注意事项: 使用syncdb 会创建一个名为cmsplugin_galleries_gallerycontainer_galleries 的表,但使用south,该表名为cmsplugin_gallerycontainer_galleries

谢谢

【问题讨论】:

  • 这可能是一个错误:south.aeracode.org/ticket/1314
  • 您使用的是 django cms 3.0 吗?如果是,请务必升级到最新的开发分支
  • 不,我使用的是 django cms 2.4.3 和南 0.8.4。我想知道是否有替代 daigorocub 的链接。手动更改迁移听起来很讨厌,但如果没有其他选择,我想我必须这样做。

标签: django django-south django-cms


【解决方案1】:

由于没有其他选择,我遵循 @daigorocub 提示并替换了迁移文件中 cmsplugin_gallerycontainer_galleries 的所有 short_name 实例

m2m_table_name = db.shorten_name(u'cmsplugin_gallerycontainer_galleries')

m2m_table_name = db.shorten_name(u'cmsplugin_galleries_gallerycontainer_galleries')

此问题已在 django cms 3.0 (https://github.com/divio/django-cms/issues/2291#ref-pullrequest-26529456) 的开发分支中修复,但由于我的版本较旧,我无法更新到最新分支

谢谢大家的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-23
    • 2012-04-26
    • 2012-03-03
    • 1970-01-01
    • 2011-10-04
    • 1970-01-01
    • 2012-03-21
    • 1970-01-01
    相关资源
    最近更新 更多