django South 全新安装 -->错误:未知命令“schemamigration”

发布于 2024-10-03 01:35:45 字数 4723 浏览 5 评论 0原文

简短的故事

我在全新安装 South ( http://south.aeracode.org/ ),并且出现以下错误:

Unknown command: 'schemamigration'
Type 'manage.py help' for usage.

编辑:我有版本 .7 (south/init.py 有 < strong>version = ".07")

长篇故事

下面几乎是刚刚发生的事情的字面复制/粘贴:

$ sudo apt-get install python-django-south
$ django-admin.py startproject junk_proj
$ cd junk_proj
$ ./managy.py startapp junk_app
$ vim settings.py #add 'south' to INSTALLED_APPS

$ cat settings.py
# Django settings for junk_proj project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

import os
CWD = os.getcwd()
DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = CWD+'/db'             # Or path to database file if using sqlite3.
DATABASE_USER = ''             # Not used with sqlite3.
DATABASE_PASSWORD = ''         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'vgtm!i0*(qn$8m9&0u_)#(5yh(kt8%+4dlwfum%xtt-$1ge+ld'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'junk_proj.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'south',
    'junk_app',
)

$ ./managy.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table south_migrationhistory

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'foo'): admin
E-mail address: [email protected]
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model

synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > south
 > junk_app

Not synced (use migrations):
 -
(use ./manage.py migrate to migrate these)
$
$./manage.py schemamigration junk_app --initial
Unknown command 'schemamigration'
Type 'manage.py help' for usage
$

short story

I run ./manage.py schemamigration junk_app --initial on a completely fresh django project right after freshly installing South ( http://south.aeracode.org/ ), and I get the following error:

Unknown command: 'schemamigration'
Type 'manage.py help' for usage.

EDIT: I have version .7 (south/init.py has version = ".07")

long story

Below is almost a literal copy/paste of what just happened:

$ sudo apt-get install python-django-south
$ django-admin.py startproject junk_proj
$ cd junk_proj
$ ./managy.py startapp junk_app
$ vim settings.py #add 'south' to INSTALLED_APPS

.

$ cat settings.py
# Django settings for junk_proj project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

import os
CWD = os.getcwd()
DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = CWD+'/db'             # Or path to database file if using sqlite3.
DATABASE_USER = ''             # Not used with sqlite3.
DATABASE_PASSWORD = ''         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'vgtm!i0*(qn$8m9&0u_)#(5yh(kt8%+4dlwfum%xtt-$1ge+ld'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'junk_proj.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'south',
    'junk_app',
)

.

$ ./managy.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table south_migrationhistory

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'foo'): admin
E-mail address: [email protected]
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model

synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > south
 > junk_app

Not synced (use migrations):
 -
(use ./manage.py migrate to migrate these)
$
$./manage.py schemamigration junk_app --initial
Unknown command 'schemamigration'
Type 'manage.py help' for usage
$

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

原来分手还会想你 2024-10-10 01:36:01

检查您使用哪个settings.py文件:

./manage.py shell
import settings
settings.__file__

您可以在manage.py中看到Django默认使用哪个设置文件:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")

或者您可以使用:

 $./manage.py schemamigration junk_app --settings=settings --initial

而不是:

 $./manage.py schemamigration junk_app --initial

check, which settings.py file you use:

./manage.py shell
import settings
settings.__file__

you may see in manage.py, which settings file Django use by defaul:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")

or you may use:

 $./manage.py schemamigration junk_app --settings=settings --initial

instead of:

 $./manage.py schemamigration junk_app --initial
溇涏 2024-10-10 01:36:00

如果您的设置位于设置文件夹中,请确保在路径中使用 . 而不是 /
示例:./manage.py schemamigration Secretballot --initial --settings=settings.jacob

If you have your settings in a settings folder, make sure you use a . and not / in the path.
Example: ./manage.py schemamigration secretballot --initial --settings=settings.jacob

帅哥哥的热头脑 2024-10-10 01:35:59

我认为这个问题可能非常难以捉摸。我花了相当多的时间,然后我发现我正在重写 INSTALLED_APPS 来进行一些测试。哎哟!所以这是关键。请务必在 INSTALLED_APPS 末尾添加 south,如果您覆盖它,也请检查它。

I think this problem can be very elusive. I spent considerable time and I then figured out that I was overriding INSTALLED_APPS for some testing. Doh! So this is key. Be sure to add south at the end of your INSTALLED_APPS and if you override it, check that too.

小…楫夜泊 2024-10-10 01:35:58

使用 easy_installpip 来安装 South,而不是使用 Ubuntu 软件包。这将确保您拥有最新版本。

Instead of using the Ubuntu package, use easy_install or pip to install South. This will ensure you have the most recent version.

千里故人稀 2024-10-10 01:35:57

您可能正在使用一些旧的 South 版本,0.6.x 甚至 0.5.x。如果您输入“./manage.py help”,您应该会在可用命令列表中看到 startmigration (iirc)。

You are probably using some old South version, 0.6.x or even 0.5.x. If you type that "./manage.py help" you should see startmigration (iirc) on the list of available commands.

凶凌 2024-10-10 01:35:56

您可能尚未将“south”添加到 settings.py 文件的 INSTALLED_APPS 列表中。

这是来自 http://south.aeracode.org/docs/installation.html#installation-configure< 的引用/a>

现在您已经在系统范围内安装了 South,您需要配置
姜戈就用它。这样做很简单;只需编辑您的settings.py 并
将“south”添加到 INSTALLED_APPS 的末尾。

如果 Django 似乎没有注意到这一点,请检查您是否没有
在其他地方覆盖 INSTALLED_APPS,并且您可以运行 import South
从 ./manage.py shell 内部没有错误。

添加 South 后,您需要运行 ./manage.pysyncdb 来使
南方迁移跟踪表(南方不使用迁移
由于各种原因,它自己的模型)。

You probably haven't added 'south' into the list of INSTALLED_APPS of your settings.py file.

Here's a quote from http://south.aeracode.org/docs/installation.html#installation-configure

Now you’ve installed South system-wide, you’ll need to configure
Django to use it. Doing so is simple; just edit your settings.py and
add 'south' to the end of INSTALLED_APPS.

If Django doesn’t seem to pick this up, check that you’re not
overriding INSTALLED_APPS elsewhere, and that you can run import south
from inside ./manage.py shell with no errors.

Once South is added in, you’ll need to run ./manage.py syncdb to make
the South migration-tracking tables (South doesn’t use migrations for
its own models, for various reasons).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文