Search code examples
pythondjangodjango-south

django south is changing my boolean data on init


To output my database to json file I would usually do

python manage.py dumptdata --indent=4 > mydata.json

However upon executing the following two commands to setup south:

python manage.py schemamigration myproj --initial
python manage.py migrate myproj --fake

I noticed that two of my booleans in mytable for an entry were switched from FALSE to TRUE! I see that from my GUI Web Interface interacting with the database however to more closely compare what changed and got corrupted I'd like to compare json to json but with south enabled I can no longer use the above command as it tells me

Not synced (use migrations):
 - myproj

My table that had entries affected is below, I could have more affected data that I have not uncovered.

class MyConfig(models.Model):
    name = models.CharField(max_length=64)
    myConfigName = models.CharField(max_length=64, unique=True)
    myA = models.ForeignKey(MyA)
    myB = models.ForeignKey(MyB)
    myBoolA = models.BooleanField()
    myBoolB = models.BooleanField()
    myBoolC = models.BooleanField()

    class Meta:
        unique_together = ('name', 'myA', 'myB')

    def __unicode__(self):
        return '%s_%s_%s' % (self.myA.name, self.myB.name, self.name)

Solution

  • schemamigration and migrate --fake don't modify the database. Do you have any initial_data fixture that could be reloaded when migrating? See https://docs.djangoproject.com/en/1.3/howto/initial-data/

    Try to migrate with:

    python manage.py migrate --no-initial-data
    

    see south doc for more info about options