2010-11-18 11 views
17

cuento

corro ./manage.py schemamigration junk_app --initial en un proyecto Django completamente nuevo justo después de la instalación recién Sur (http://south.aeracode.org/), y me sale el siguiente error:Django sur nueva instalación -> error: comando desconocido 'schemamigration'

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

EDIT: tengo la versión 0.7 (sur/init.py tiene versión =" 0.07")

larga historia

A continuación se muestra una copia casi literal/pegar de lo que acaba de ocurrir:

$ 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 
$ 
+1

¿Qué versión de South descargaste? 'schemamigration' no apareció en versiones anteriores. ¿Qué obtienes cuando escribes './Manage.py' sin argumentos? –

+0

'subcomandos disponibles: limpieza compilemessages convert_to_south createcachetable createsuperuser dbshell diffsettings dumpdata ras inspectdb loaddata makemessages migrar restablecer runfcgi runserver shell sql sqlall sqlclear sqlcustom sqlflush sqlindexes sqlinitialdata sqlreset sqlsequencereset startapp startmigration syncdb prueba testserver validar ' –

+1

no recomendaría el uso de' apt-GET' para este tipo de cosas. Nada en su sistema operativo depende de South, por lo que no hay ninguna razón para vincularse a la versión anterior que se haya empaquetado para su sistema operativo. Use 'pip' en su lugar. –

Respuesta

8

Probablemente estés usando alguna versión antigua del Sur, 0.6.xo incluso 0.5.x. Si escribe esa "./manage.py help", debería ver startmigration (iirc) en la lista de comandos disponibles.

+1

Además, en 0.7 'startmigration' se dividió en' schemamigration' y 'datamigration'. No había un equivalente real para 'datamigration' en versiones anteriores; tenías que hacer 'startmigration' y luego reemplazar el código de migración tú mismo. –

+0

¿Cómo puedo saber qué versión de South tengo? Solo veo la opción de migración inicial cuando escribo ./manage.py ayuda, pero eso no tiene sentido porque acabo de instalar vía apt-get en una máquina Ubuntu 10 (nunca he editado el archivo de fuentes). ¿Cómo podría tener una versión obsoleta de South, y cómo puedo encontrar oficialmente la versión que tengo? –

+0

startmigration funcionó, por cierto, pero aún me gustaría saber la versión que estoy usando. –

4

En lugar de usar el paquete Ubuntu, use easy_install o pip para instalar South. Esto asegurará que tengas la versión más reciente.

35

Probablemente no haya agregado 'sur' en la lista de INSTALLED_APPS de su archivo settings.py.

Aquí es una cita de 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).

+0

Añadiendo 'sur' a la lista de INSTALLED_APPS salvó mi día :-) Gracias. – Hartmut

+0

Agregué ''sur',' al final de mi INSTALLED_APPS y todavía no se reconoce. ¿Algunas ideas? Estoy usando virtualenv en Windows 7. – aldo

+1

Esta parte es muy importante !!! 'Si Django no parece entender esto, compruebe que no está anulando INSTALLED_APPS en otro lugar, y que puede ejecutar la importación hacia el sur desde el interior del shell ./manage.py sin errores. – nicorellius

1

cheque, que settings.py archivo que utiliza:

./manage.py shell 
import settings 
settings.__file__ 

que puede ver en manage.py, que los ajustes del archivo de Django uso por defaul:

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

o puede usar:

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

en lugar de:

$./manage.py schemamigration junk_app --initial 
1

Si usted tiene su configuración en una carpeta de configuración, asegúrese de usar un . y no / en la ruta. Ejemplo: ./manage.py schemamigration secretballot --initial --settings=settings.jacob

3

Creo que este problema puede ser muy elusivo. Pasé un tiempo considerable y luego me di cuenta de que estaba anulando INSTALLED_APPS para algunas pruebas. Doh! Entonces esta es la clave. Asegúrese de agregar south al final de su INSTALLED_APPS y si lo reemplaza, verifique también.

Cuestiones relacionadas