Set default value on migration Django/South?

474 views Asked by At

Is Django 1.6 with South 0.8 going to set default value when I add a column with default value to existing data having the field described like this?

gametype = models.PositiveSmallIntegerField(_('type of game'), 
                                            choices=CONST_TYPES, 
                                            default=CONST_TYPE_NORMAL, 
                                            null=True, blank=True)

I am worrying about having null=True at the same time with default specified

1

There are 1 answers

0
seddonym On BEST ANSWER

It depends on whether gametype is a new field or not.

  1. If the gametype field is a new field, the migration will add that field to every model instance and use the default value.
  2. However, if the gametype field already existed and there are values in the database already, South shouldn't mess with them, even if they're NULL.