Essentially it seems the dumpscript is skipping a many-to-one field
when generating the script, which obviously gets noticed when I try a
runscript and get told the required field team_id is missing, and
indeed it is:
match_match_1 = Match()
match_match_1.date = datetime.datetime(2008, 8, 17, 10, 30)
match_match_1.home_or_away = u'A'
match_match_1.opponents = u'Hannikins Farm'
match_match_1.own_goals = 0L
match_match_1.goals_for = 0L
match_match_1.goals_against = 4L
match_match_1.competition = match_competition_5
In the model team_id comes before date. The old database has 750 rows
which all have a team_id set, the new database has the required fields
in place waiting to be filled, but the data appears to be getting
skipped. I see a warning about if the relationship is new but it's
been there for a few years. I know 750 rows isn't vast but I'd still
rather not hand edit the thing if anyone has come across this before
or has ideas so... Any hints/tips/suggestions folks?
dumpscript does this because it wants to avoid setting id values and
use actual model instances, but if the team model instances haven't
been created yet, they can't be set at the beginning. They should
appear later in the script.
Let me know if this isn't the case.
Team is actually from a different models.py so that's imported at line
team = models.ForeignKey(Team) <-- line 32
More a puzzler than anything else though, dumpscript has worked
flawlessly every other time so I've been assuming it's something weird
in my models.py - I just can't see anything out of the ordinary so
Ah ok, maybe that's what's confusing dumpscript, I'll see if I can
create a failing test. What version of django are you on?
This was all on Django 1.1.1 and Python 2.6.4.
Unfortunately as team is pretty much the constant foreign key holding
together the other apps it stood out as the issue, but there are a
couple of other places where the apps inter-connect and it seems to
basically be happening in those cross-app foreign keys