首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >django south fresh install -->错误:未知命令'schemamigration‘

django south fresh install -->错误:未知命令'schemamigration‘
EN

Stack Overflow用户
提问于 2010-11-18 19:01:57
回答 6查看 17.2K关注 0票数 17

短篇故事

我在一个全新的django项目上运行./manage.py schemamigration junk_app --initial,在刚刚安装了South ( http://south.aeracode.org/ )之后,我得到了以下错误:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Unknown command: 'schemamigration'
Type 'manage.py help' for usage.

编辑:I have version (south/init.py .7 version = ".07")

说来话长

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$ 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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$ cat settings.py
# Django settings for junk_proj project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

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',
)

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$ ./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: admin@example.com
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
$
EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2010-11-18 19:06:05

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

票数 8
EN

Stack Overflow用户

发布于 2012-01-29 16:37:50

您可能还没有将'south‘添加到settings.py文件的INSTALLED_APPS列表中。

下面是http://south.aeracode.org/docs/installation.html#installation-configure的一句话

Django现在已经在系统范围内安装了

,您需要配置Django才能使用它。这样做很简单;只需编辑settings.py并在INSTALLED_APPS的末尾添加“south”即可。

如果Django似乎没有注意到这一点,请检查您是否没有覆盖其他地方的INSTALLED_APPS,以及您是否可以从./manage.py shell内部运行import south而不会出现错误。

一旦将South添加进来,您将需要运行./manage.py syncdb来创建South迁移跟踪表(出于各种原因,South不会将迁移用于其自己的模型)。

票数 35
EN

Stack Overflow用户

发布于 2010-11-18 19:26:55

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4218496

复制
相关文章

相似问题

领券
社区富文本编辑器全新改版!诚邀体验~
全新交互,全新视觉,新增快捷键、悬浮工具栏、高亮块等功能并同时优化现有功能,全面提升创作效率和体验
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文