当我进行迁移时python manage.py makemigrations wall
我在控制台中看到Django(1.8.12)告诉我一长串被触及的字段:
Migrations for 'wall':
0079_auto_20170302_0024.py:
- Add field periodic_task_interval to userproject
- Alter field bank_problems on bankireference
- Alter field bank_problems_category on bankireference
- Alter field bank_products on bankireference
- Alter field bank_products_category on bankireference
- Alter field extr_category on bankireference
- Alter field extr_words on bankireference
- Alter field neg_features on bankireference
- Alter field neutral_features on bankireference
- Alter field pos_features on bankireference
- Alter field tonality_category on bankireference
- Alter field tonality_words on bankireference
- Alter field bank_problems on fbpagepost
- Alter field bank_problems_category on fbpagepost
- Alter field bank_products on fbpagepost
- Alter field bank_products_category on fbpagepost
- Alter field extr_category on fbpagepost
......广告等等,靠近所有文件,即ManyToManyField。我还检查了其他迁移,看起来像随机选择字段,因为我也看到tagulous.models.fields.TagField
乃至
models.TextField
。
但是,我确信没有改变那些字段,甚至触及它们
这是0079_auto_20170302_0024.py中未触及的字段:
......
migrations.AlterField(
model_name='userproject',
name='description',
field=models.TextField(default='', verbose_name='Description', blank=True, null=True),
),
......
我唯一做的就是添加- Add field periodic_task_interval to userproject
所以其他字段 - 为什么它们出现在迁移中?
由于数据库庞大,这会影响很长时间吗?
答案 0 :(得分:1)
如果您在字段中具有choices =参数,则应以“稳定方式”(每次都相同的顺序)生成它,例如使用sorted()
TYPES = {
'DISTRICT': 'Округ',
'AREA': 'Район',
'STATION': 'Станция метро',
}
type = models.CharField(
max_length=255,
choices=sorted(TYPES.items()),
default='AREA',
)