首先,我创建我的数据库。
create database mydb;
我将“南”添加到已安装的应用程序中。然后,我去这个教程: http ://south.aeracode.org/docs/tutorial/part1.html
本教程告诉我这样做:
$ py manage.py schemamigration wall --initial
>>> Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate wall
太好了,现在我迁移。
$ py manage.py migrate wall
但它给了我这个错误......
django.db.utils.DatabaseError: (1146, "Table 'fable.south_migrationhistory' doesn't exist")
所以我使用谷歌(它从来没有用过。因此我在 Stackoverflow 上提出了 870 个问题),我得到了这个页面:http ://groups.google.com/group/south-users/browse_thread/thread/d4c83f821dd2ca1c
好的,所以我按照说明进行操作
>> Drop database mydb;
>> Create database mydb;
$ rm -rf ./wall/migrations
$ py manage.py syncdb
但是当我运行 syncdb 时,Django 会创建一堆表。是的,它创建了 south_migrationhistory 表,但它也创建了我的应用程序的表。
Synced:
> django.contrib.admin
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.sites
> django.contrib.messages
> south
> fable.notification
> pagination
> timezones
> fable.wall
> mediasync
> staticfiles
> debug_toolbar
Not synced (use migrations):
-
(use ./manage.py migrate to migrate these)
酷......现在它告诉我迁移这些。所以,我这样做:
$ py manage.py migrate wall
The app 'wall' does not appear to use migrations.
好吧,很好。我将在初始迁移中添加墙。
$ py manage.py schemamigration wall --initial
然后我迁移:
$ py manage.py migrate wall
你知道吗?它给了我这个BS:
_mysql_exceptions.OperationalError: (1050, "Table 'wall_content' already exists")
对不起,这真的让我很生气。有人可以帮忙吗?谢谢。
如何让 South 正常工作并与所有内容正确同步?我唯一能想到的就是从 INSTALLED_APPS 中删除我的应用程序,然后运行 syncdb,然后重新添加它。
那太傻了。