Django 1.2 brings multiple databases handling through the use of database routers. The actual version of South (0.7.3) is not able to handle correctly multiple databases projects out of the box.
Here is a workaround: the idea is to create a new fake django project. And then to use South migration within this project.
1
2
3
|
cd head_directory
django-admin.py startproject my_south_db_project
cd my_south_db_project
|
Next,edit my_south_db_project/settings.py
- we have to set the path correctly to south, to your app and to the corresponding database
- The only installed apps should be South and your app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import sys
import os.path
current_path = os.path.abspath(os.path.dirname(_ _file_ _))
head, tail = os.path.split(current_path)
sys.path.append(os.path.join(head, "my_db_app_dir"))
sys.path.append(os.path.join(head, "south_sdir"))
dbpath = os.path.join(head, "my_initial_project_dir")
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME' : os.path.join(dbpath,'my_db_app.sqlite'),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
},
}
INSTALLED_APPS = ( 'south', 'my_db_app',)
|
Create south table in the new db
Now you can work in this project to manage your apps related to this new db
1
2
3
4
5
|
manage.py convert_to_south my_db_app on other computers
manage.py migrate my_db_app 0001 --fake modify models.py
manage.py schemamigration my_db_app --auto manage.py migrate my_db_app
|
As you can see, this way you keep the standard South workflow !
Edit: I use this line in the main project’s settings.py in order to be able to launch tests:
SOUTH_TESTS_MIGRATE = False