Ich hab mal eine kleine Test app gebaut. Das Problem kommt dann auf, wenn man die models.py in einem Verzeichnis aufteilt.Error: One or more models did not validate:
django_test.article: 'publications' has a manually-defined m2m relation through model Article_publications, which does not have foreign keys to Publication and Article
Es sieht dann so aus:
./models/article.py
Code: Alles auswählen
from django.db import models
class Article(models.Model):
headline = models.CharField(max_length=100)
publications = models.ManyToManyField("Publication", null=True, blank=True,)
class Meta:
app_label = 'django_test'
./models/publication.py
Code: Alles auswählen
from django.db import models
class Publication(models.Model):
title = models.CharField(max_length=30)
class Meta:
app_label = 'django_test'
./models/__init__.py
Code: Alles auswählen
from article import Article
from publication import Publication