【发布时间】:2011-06-02 06:47:35
【问题描述】:
考虑以下(简化的)Django 模型:
class productFamily(models.Model):
name = models.CharField(max_length = 256)
text = models.TextField(blank = False)
image = models.ImageField(upload_to="products/img/")
def __unicode__(self):
return self.name
class productModel(models.Model):
productFamily = models.ForeignKey('productFamily')
productFamily.help_text = 'ProductFamily to which this model belongs.'
artNumber = models.CharField(max_length=100)
name = models.CharField(max_length = 256)
productDownloads = models.ManyToManyField('productModelDownLoad')
productDownloads.help_text = 'Files associated to this product Model.'
def __unicode__(self):
return self.name
class productModelDownload(models.Model):
file = models.FileField(upload_to="products/downloads/")
def __unicode__(self):
return str(self.file)
我收到以下错误:
products.productmodel: 'productDownloads' 与模型 productModelDownLoad 具有 m2m 关系,该模型要么尚未安装,要么是抽象的。
我在 django 文档中找到了一个似乎解决这个问题的页面,但我不太明白它的含义: http://www.djangoproject.com/documentation/models/invalid_models/
模型在我看来是有效的,那么这里有什么问题?
【问题讨论】:
标签: django django-models