Lets say I have two django apps:
- competitions - which will handle competition data
- entries - which will handle functionality relating to entering competitors into competitions
In the competitions app I have a model which represents a section of a competition:
class Division(models.Model):
competition = models.ForeignKey(Competition)
discipline = models.CharField(max_length=1, choices=DISCIPLINE_CHOICES)
age_group = models.ForeignKey(AgeGroup)
participants = models.ManyToManyField(Competitor, through='Entry')
I want to put the Entry model in the entries app:
class Entry(models.Model):
division = models.ForeignKey('Division')
competitor = models.ForeignKey(Competitor)
withdrawn = models.BooleanField(default=False)
How do I solve the from ... import ... statements, so that they work? When I put in import statements such as from entries.models import Entry
I get the models from these apps ignored by syncdb (because the imports are circular) or when I remove one or both of them I get validation errors:
Error: One or more models did not validate: entries.entry: 'division' has a relation with model Division, which has either not been installed or is abstract. competitions.division: 'participants' specifies an m2m relation through model Entry, which has not been installed
I understand why this happens, but I have no idea how to change this, so that it works (without resorting to moving the Entry model into the competitions app, which I really don't want to do).
Competitor
class? – Institutionalism