Question

After being inspired by django-oscar, I tried to put a cmsplugin inside its main app. However, after doing a schemamigration --initial I can't use the plugin in Django CMS.

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

App Tree

  • gallery
    • apps
      • cmsplugin_galleries
        • migrations
        • cms_plugins.py
        • init.py
        • models.py
      • init.py
    • migrations
    • static
    • templates
    • admin.py
    • init.py
    • models.py
    • views.py

Gallery models

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 models

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

Since I can properly run it using syncdb --all, what did I do wrong?

Notes: Using syncdb creates a table with the name cmsplugin_galleries_gallerycontainer_galleries but using south, the table name is cmsplugin_gallerycontainer_galleries

Thanks

Était-ce utile?

La solution

Since there was no other alternative I followed @daigorocub tip and replaced all the shorten_name instances of cmsplugin_gallerycontainer_galleries inside the migration file

m2m_table_name = db.shorten_name(u'cmsplugin_gallerycontainer_galleries')

to

m2m_table_name = db.shorten_name(u'cmsplugin_galleries_gallerycontainer_galleries')

This issue was fixed in the development branch of django cms 3.0 (https://github.com/divio/django-cms/issues/2291#ref-pullrequest-26529456) but since my version is older I couldn't update to the latest branch

Thank you guys for your help!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top