0
で日付フィールドをクリーンアップしようとしている私は、モデルがあります:Djangoの移行エラー、不正なデフォルト
class Season(models.Model):
""" Corresponds to your brochure publishing schedule, e.g. Fall/Winter 2012, Sprint 2014, etc. """
name = models.CharField(max_length=45, db_index=True, unique=True)
start_date = models.DateField(db_index=True, help_text="The date enrollment can begin this Season.")
<snip>
モデルの事前日付の移行を、私は南を使用していませんでした。
start_dateのフィールドには、日付フィールドのために意味をなさないdoesntのこの定義
start_date = models.DateField(db_index=True, default=False,
help_text="The date of the first Session of this Season.")
私は実際にヘルプテキストを編集することで行って、デフォルトに気づい= Falseのと考え、と長年住んでいました私が馬鹿だったときから残っているに違いない。
だから私はそれを取り出した。
今私の移行:
class Migration(migrations.Migration):
dependencies = [
('district', '0012_auto_20160622_1741'),
]
operations = [
migrations.AlterField(
model_name='season',
name='start_date',
field=models.DateField(help_text=b'The date enrollment can begin this Season.', db_index=True),
),
]
はで失敗:
Applying district.0013_auto_20170204_1811...Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/verylongpathtovenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 222, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/migrations/executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/migrations/executor.py", line 148, in apply_migration
state = migration.apply(state, schema_editor)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/migrations/migration.py", line 115, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 201, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 484, in alter_field
old_db_params, new_db_params, strict)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 566, in _alter_field
old_default = self.effective_default(old_field)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 211, in effective_default
default = field.get_db_prep_save(default, self.connection)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 710, in get_db_prep_save
prepared=False)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1322, in get_db_prep_value
value = self.get_prep_value(value)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1317, in get_prep_value
return self.to_python(value)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1274, in to_python
parsed = parse_date(value)
File "/verylongpathtovenv/lib/python2.7/site-packages/django/utils/dateparse.py", line 60, in parse_date
match = date_re.match(value)
TypeError: expected string or buffer
TypeError例外研究する:期待される文字列をかをバッファリングは、私がしようとしている何をやっていないについての議論を思い付きます元に戻す、つまり、日付フィールドのデフォルトを日付のようなものに設定しないでください。
これを進める方法が不明です。任意のヒントをいただければ幸いです。
は、makemigrationsコマンドによって作成された移行であったか、自分でやったか?なぜ、help_textはバイトテストですか? – trixn
これはmakemigrationsで作成されました。私はdjangoがヘルプテキストをバイトテキストとして見ているのかどうかはわかりません。 –