【问题标题】:Error: One or more models did not validate: Django+South, shemamigration generic --auto错误:一个或多个模型未验证:Django+South,shemamigration generic --auto
【发布时间】:2011-11-14 15:20:10
【问题描述】:

我正在尝试运行 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')

解决了!

Meta 类中的文章有app_label = 'Generic' 而不是'generic'

【问题讨论】:

  • 这个问题最终可能会因为过于本地化而被关闭,但与此同时,请添加您的“已解决”评论作为答案,并接受它。这是 StackOverflow 上的标准操作程序,您可以在任何时候自行找到解决方案,并有助于保持 StackOverflow 的清洁。

标签: django migration django-south


【解决方案1】:

Meta 类中的文章有 app_label = 'Generic' 而不是 'generic'

【讨论】:

    猜你喜欢
    • 2013-02-13
    • 2011-02-06
    • 2014-03-07
    • 1970-01-01
    • 2015-02-08
    • 2013-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多