From many to many relationships that have either not been established or are abstract

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 a m2m relationship with the model product ModelLDownLoad, which has either not been installed or is abstract.

I found a page in django docs that seems to address this, but I can't figure out what this means: http://www.djangoproject.com/documentation/models/invalid_models/

The model looks right to me, so what's the problem?

+6
django django-models
source share
3 answers

Interestingly, there are two ways to solve this problem:
a) Thomas will answer the trick,
b) But so does Mike Korobov:
The field name has a wandering capital letter:

productDownloads = models.ManyToManyField ('productModelDown * L * oad')

Correcting this impartial capital also solves this problem.

+1
source share

You must place the productModelDownload class in front of the productModel class. They are processed from top to bottom when checking models.

+9
source share

models.ManyToManyField ('productModelDownLoad') - "Download" is in upper case

class productModelDownload (models.Model): - 'load' is lowercase

+2
source share

All Articles