django 1.7测试/应用迁移到新数据库时的迁移问题(将现有的django 1.5项目升级到django 1.7)

时间:2014-11-19 10:53:48

标签: python django django-models django-south django-migrations

我已将旧的Django 1.5版本项目升级到新的Django 1.7版本

我的主要问题是迁移。

我按照upgrading from south to django migrations进行了新的迁移。

现在,当我运行测试用例./manage.py test时,在创建testDB时出现错误,并且在将迁移应用到新数据库./manage.py migrate

时会发生同样的错误
Applying someapp.0001_initial...Traceback (most recent call last):
  File "manage.py", line 18, in <module>
    execute_from_command_line(sys.argv)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 160, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 63, in migrate
    self.apply_migration(migration, fake=fake)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 97, in apply_migration
    migration.apply(project_state, schema_editor)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 107, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 37, in database_forwards
    field,
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 390, in add_field
    self.execute(sql, params)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 99, in execute
    cursor.execute(sql, params)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/user/django17/django17_env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.InternalError: current transaction is aborted, commands ignored until end of transaction block

任何人都可以帮助我解决这个问题,这可能是迁移的错误

1 个答案:

答案 0 :(得分:0)

似乎:

  

... 0001_initial

导致您的错误。这可能是从南方监督的移民吗?我建议清空所有迁移包(但不是init文件!)并使用(windows)重新命令命令行中的迁移:

$ cd <your projects'-path>
$ python manage.py makemigrations
$ python manage.py migrate