Smarter evolve

Skip to first unread message


Dec 27, 2008, 1:17:54 PM12/27/08
to Django Evolution
Hi guys, I have something like this:

class Person(models.Model):

class Pet(models.Model):
name = models.CharField(max_length = 50)

class Person_owns_Pet(models.Model):
person = models.ForeignKey(Person)
pet = models.ForeignKey(Pet)

This is obviously wrong and I need to migrate this by adding the
"person" field to the Pet as a foreignkey.

My mutation looks like this:
AddField('Pet', 'person', models.ForeignKey,
initial=initial_function, related_model='personpet.Person'),

And this doesn't seem to work as evolve --execute keeps
complaining as if the evolutions folder wasn't in the PetPerson app.
The fill_person_in_pet function in the middle of MUTATIONS was my hope
that the function got executed filling correctly the newly created
Pet.person field from Person_owns_Pet.
The inital_function returns the first id of the first Person found.

A good way to do this was to be able to give initial_function an
argument with the Pet id so that it would return the right Person
right away.

Can you help me accomplish this?

Thank you,
Reply all
Reply to author
0 new messages