Problems installing South with Django (south_migra

2019-06-22 01:34发布

问题:

I cannot seem to get this working.

I need South to do migrations for a bunch of apps.

  1. Downloaded south 0.7.3
  2. Unzipped, ran setup.py develop (as it says in the turorial)
  3. Double checked to see if it south is where it should be by going to python interpreter and doing (no errors)

    import south

  4. I do

C:\Users\j\iMiCode\imi_admin>python ./manage.py syncdb

Syncing... No fixtures found.

Synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > django.contrib.messages
 > django.contrib.admin

Not synced (use migrations): 
 - south (use ./manage.py migrate to migrate these)

-At this point from what I understand south should have been synced correct? Anything else I do after this, complains that I have no south_migrationhistory tables in the database.

PS. I am working with Django 1.2.7, python 2.6, on Windows7

回答1:

It seems to me like a bug in South.

Also this may be cause by doing wrong thigs like: running schemamigration --auto south and etc. My suggestion would be install it by running python setup.py install or through easy_install or pip

South documentation says: "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)."

But your output says that south skipped making tables for its own models because it thought south app used migrations

As a workaround you could use

python manage.py syncdb --all

Which causes all tables regardless of migrations to be synchronized and

python manage.py migrate --fake 

to fake migrations.



回答2:

For a new app, with no existing tables the steps to adding south are this:

  1. add 'south', to the list of INSTALLED_APPS.

  2. make sure the app you need to migrate is also in INSTALLED_APPS.

  3. run ./manage.py syncdb (or python manage.py syncdb from inside your project directory). This adds the migration tables to the database.

  4. from the command line, perform ./manage.py schemamigration yourappname --initial

  5. run ./manage.py migrate yourappname

Based on the error you're giving, it sounds like after step 1 & 2 you forgot to run syncdb to create the migration tables, and the South app isn't finding the place it wants to store schema migrations.



回答3:

I ran into this same issue. Turns out, by some magics, I had created migrations inside of hte south app.

Discovered by:

~ $ # cd to python library
~ $ cd `python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`
python2.7/site-packages $ cd south
python2.7/site-packages/south $ ls migrations
   0001_initial.py  0002_initial.py 0003_initial.py __init__.py

These are bad, should not be there, and is what triggers south to skip itself. Removed all things south, reinstalled, then syncdb once again worked.

python2.7/site-packages $ rm -rf south* South*
~ $ pip install south