【问题标题】:South migration schemamigration doesn't work南迁移模式迁移不起作用
【发布时间】:2012-09-08 02:18:29
【问题描述】:

为了确保我在当前的 django 项目中设置正确,我做了以下操作:

  • 向南添加到 installed_apps
  • manage.py syncdb(使用 windows)
  • manage.py convert_to_south 应用程序

我还没有对我的数据库进行更改,但无论我是否这样做,我都会运行:

  • manage.py schemamigration app --auto

我收到以下错误:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute
_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196, in run_from_ar
gv
    self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "C:\Python27\lib\site-packages\south\management\commands\schemamigration.py", line 98, i
n handle
    old_orm = last_migration.orm(),
  File "C:\Python27\lib\site-packages\south\utils.py", line 62, in method
    value = function(self)
  File "C:\Python27\lib\site-packages\south\migration\base.py", line 418, in orm
    return FakeORM(self.migration_class(), self.app_label())
  File "C:\Python27\lib\site-packages\south\orm.py", line 46, in FakeORM
    _orm_cache[args] = _FakeORM(*args)
  File "C:\Python27\lib\site-packages\south\orm.py", line 125, in __init__
    self.models[name] = self.make_model(app_label, model_name, data)
  File "C:\Python27\lib\site-packages\south\orm.py", line 318, in make_model
    field = self.eval_in_context(code, app, extra_imports)
  File "C:\Python27\lib\site-packages\south\orm.py", line 236, in eval_in_context
    return eval(code, globals(), fake_locals)
  File "<string>", line 1
    SouthFieldClass(default=datetime.datetime(2012, 9, 14, 20, 46, 3, 957000, tzinfo=<UTC>))
                                                                                     ^
SyntaxError: invalid syntax

发生了什么事? 它不允许我使用模式迁移。一直在搜索很多地方并删除和重置数据库以及所有内容,似乎无法找出问题所在。

问题已解决:

不知道 south_migrationhistory 的位置。我一直想知道一些额外的信息挂在哪里。

【问题讨论】:

    标签: database django django-south


    【解决方案1】:

    看看这里:http://south.aeracode.org/ticket/1069

    这是一个已在较新的 South 版本中修复的错误。看来您使用的是过时版本的 South(

    【讨论】:

    • 相当肯定我有 0.7.6,我一个月前才发现南方。万一我不这样做并且我必须测试新版本,我是否应该删除迁移和数据库并重新同步并再次转换应用程序?
    • 删除 South 的旧安装并重新安装新版本。关于数据库,您只需删除数据库的south_migrationhistory 表。这是 South 用来存储迁移特定数据的表。
    • 非常感谢。我自己很难通过这些东西。我的问题是不知道 south_migrationhistory,所以我猜每次我尝试重做该过程时都会导致一些问题。
    猜你喜欢
    • 1970-01-01
    • 2012-01-11
    • 1970-01-01
    • 2013-02-02
    • 2023-03-05
    • 1970-01-01
    • 2023-03-14
    • 2011-04-03
    相关资源
    最近更新 更多