【发布时间】: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