简体   繁体   中英

Set default value on migration Django/South?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM