@JsDev

Проблема migrate django?

После замены в модели поля datetime на timestamp
python manage.py migrate
Выдает ошибку
WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.
Operations to perform:
  Apply all migrations: admin, auth, blog, contenttypes, sessions
Running migrations:
  Applying blog.0007_auto_20170126_1534...Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/heavy/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 84, in database_forwards
    field,
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 231, in add_field
    self._remake_table(model, create_fields=[field])
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 113, in _remake_table
    self.effective_default(field)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 221, in effective_default
    default = field.get_db_prep_save(default, self.connection)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 755, in get_db_prep_save
    prepared=False)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1438, in get_db_prep_value
    value = self.get_prep_value(value)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1417, in get_prep_value
    value = super(DateTimeField, self).get_prep_value(value)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1275, in get_prep_value
    return self.to_python(value)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1378, in to_python
    parsed = parse_datetime(value)
  File "/home/heavy/.local/lib/python2.7/site-packages/django/utils/dateparse.py", line 93, in parse_datetime
    match = datetime_re.match(value)
TypeError: expected string or buffer

Помогите пофиксить баг
  • Вопрос задан
  • 368 просмотров
Решения вопроса 1
zelsky
@zelsky
Если база свежая, просто удалите все миграции в апп и оставьте только __init__.py
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы