django - Data not modified during South datamigration -


i doing migration adds referral code custom user model. field i've added looks this:

refer_code = models.charfield(max_length=10, default=uuid_10) 

in datamigration i've added following:

for u in orm['app.user'].objects.all():     u.refer_code = uuid_10()     print u.name + ': ' + u.refer_code     u.save() 

however, when perform migrations, of users have same code. different codes each user spat out print command, it's not problem function.

weirdly, if roll datamigration (it has no backwards method) previous migration added field, , re-apply them, not every model have same data in, has same data in before.

there other parts of datamigration (adding objects database get_or_create) working fine.

what on earth going on?

i think function called rather new field created. try 2 migrations. first add new field default value. , second fill field.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -