Consider the following (simplified) Django Models:
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)
I get the following error:
products.productmodel: ‘productDownloads’ has an m2m relation with model productModelDownLoad, which has either not been installed or is abstract.
I found a page in the django docs that seems to address this, but i can’t quite make sense of what it means:
http://www.djangoproject.com/documentation/models/invalid_models/
The Model looks valid to me, so what is the problem here?
Interestingly there are two ways to solve this:
a) Thomas’s answer does the trick,
b) But, so does Mike Korobov’s:
There is a stray capital letter in the field name in the relation:
Correcting this stray capital also resolves this issue.