Search code examples
djangomigrationdjango-south

Error: One or more models did not validate: Django+South, shemamigration generic --auto


Im trying to run the shemamigration generic --auto

    generic.articletocategory: 'article' has a relation with model generic.Article, which has either not been installed or is abstract.
    generic.category: 'articles' is a manually-defined m2m relation through model ArticleToCategory, which does not have foreign keys to Article and Category


class ArticleToCategory(m.Model):    
    article = m.ForeignKey('generic.Article')
    category = m.ForeignKey('generic.Category')

    class Meta:
        app_label = 'generic' 
        db_table = 'articles_to_categories'
        verbose_name_plural = 'ArticlesToCategories'

class Article(m.Model):
    pass


class Category(MPTTModel):
    parent = TreeForeignKey('self', null=True, blank=True, related_name='children')

    # relationships
    articles = m.ManyToManyField('generic.Article', through='generic.ArticleToCategory')

Solved!

the article in the Meta class has app_label = 'Generic' instead of 'generic'


Solution

  • the article in the Meta class has app_label = 'Generic' instead of 'generic'