xem xét như sau (giản thể) Django Models:Nhiều người đến Nhiều mối quan hệ đó đã hoặc chưa được cài đặt hoặc là trừu tượng
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)
tôi nhận được lỗi sau:
products.productmodel: 'productDownloads' has an m2m relation with model productModelDownLoad, which has either not been installed or is abstract.
Tôi tìm thấy một trang trong tài liệu django dường như giải quyết vấn đề này, nhưng tôi hoàn toàn không hiểu ý nghĩa của nó: http://www.djangoproject.com/documentation/models/invalid_models/
Mô hình có vẻ hợp lệ với tôi, vì vậy, là vấn đề ở đây?
Phần thú vị là bằng cách thay đổi thứ tự của các mô hình, chúng cũng được xác nhận. Điều này thậm chí còn mong muốn? –