【问题标题】:Trouble while adding south to existing app将南添加到现有应用程序时出现问题
【发布时间】:2015-05-16 09:14:20
【问题描述】:

我正在关注 djano-rest-framework 教程。我正在尝试为数据库迁移添加南。这就是我的pip freeze 的样子:

Django==1.8.1
djangorestframework==3.1.2
MySQL-python==1.2.5
Pygments==2.0.2
South==1.0.2

tutorial 项目的 settings.py 如下所示:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'snippets',
    'south'
)
...
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'snippets',
        'HOST': 'localhost',
        'PORT': 3306,
        'USER': 'abcd',
        'PASSWORD': ''
    }
 }

SOUTH_DATABASE_ADAPTERS = {
    'default': 'south.db.mysql'
}

我在运行./manage.py syncdb 时收到以下错误:

/home/superq/learn-django/env/lib/python2.7/site-packages/south/db/generic.py:9: RemovedInDjango19Warning: The django.db.backends.util module has been renamed. Use django.db.backends.utils instead.
  from django.db.backends.util import truncate_name

There is no South database module 'south.db.mysql' for your database. Please either choose a supported database, check for SOUTH_DATABASE_ADAPTER[S] settings, or remove South from INSTALLED_APPS.

我已经多次安装和卸载了南。有什么想法吗?

【问题讨论】:

    标签: python django migration django-south


    【解决方案1】:

    您使用的是 Django 1.8。没有理由添加 South:自 1.7 以来的 Django 版本已包含内置迁移。事实上,South 文档明确声明它与 1.7+ 不兼容。

    【讨论】:

    • 我打开 shell 并尝试执行“import south”。它说没有这样的模块可用。
    • 是的。为什么要这么做?我刚才说了,South 不是必需的,也不兼容 1.8。
    • 我正在尝试,因为 schemamigration 或 startmigration 命令都不适用于 manage.py
    • 没有,因为 Django 1.7/1.8 有自己的迁移命令,即fully explained in the documentation
    • 我的错。现在会彻底看看它。任何其他示例资源也将不胜感激。谢谢!
    猜你喜欢
    • 2014-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多