makemigrations
django 1.7のコマンドによって変更がどのように検出されますか?
私のフィールドの1つに変更があるのに、変更がないことが常に通知されるという問題があります。コマンドを実行すると、同じ移行ファイルが変更なしで何度も書き込まれます。
このフィールドは、deconstruct メソッドを実装したカスタム フィールドであり、オブジェクトであるパラメーターがいくつかあるため、deconstructible デコレーターを使用しました。
問題を再現する github でプロジェクトを作成しました: https://github.com/YAmikep/django-testmigrations
私は何を間違えましたか?これはバグですか?
これが私が実行したものです:
/projects/testmigrations$ python manage.py makemigrations app1
Migrations for 'app1':
0001_initial.py:
- Create model ModelA
/projects/testmigrations$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, contenttypes, auth, app1, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying app1.0001_initial... OK
Applying sessions.0001_initial... OK
/projects/testmigrations$ python manage.py makemigrations
Migrations for 'app1':
0002_auto_20141014_2123.py:
- Alter field field1 on modela
/projects/testmigrations$ python manage.py makemigrations
Migrations for 'app1':
0003_auto_20141014_2123.py:
- Alter field field1 on modela
移行ファイル 0002_auto_20141014_2123.py と 0003_auto_20141014_2123.py には、まったく同じ操作が含まれています。
operations = [
migrations.AlterField(
model_name='modela',
name='field1',
field=app1.models.CustomField(max_length=50, value_manager=app1.models.ValueManager(values=[app1.models.Value(val=1), app1.models.Value(val=2)])),
),
]