I'm having trouble trying to add south to an existing django project. Here is my situation:
My project is called alerts. Here is my folder structure:
djangoprojects/
alerts/
manage.py
alerts/
__init__.py
urls.py
views.py
models.py
wsgi.py
settings.py
common/
__init__.py
models/
__init__.py
models.py
The file alerts/alerts/models.py has the following content:
from common.models.models import *
In other words, the only thing that alerts/alerts/models.py does is import the "real" models from alerts/common/models/models.py, which has a large number of models that were created from a past project.
I also have a MYSQL database that I'll call 'existing_database'. This is the database that corresponded to the models on my past project, which ran on another machine. On that other machine I used mysqldump to get the sql file for this database and copied it over to my new machine. Then I used mysql directly to create existing_database on my new machine. So now the database existing_database should match the models in alerts/common/models/models.py.
So next I went through the documentation to try to add south to the alerts project. This is what I did:
- I added 'south' and 'alerts' to the INSTALLED_APPS inside alerts/alerts/settings.py. I'm not sure why I have to add 'alerts' to settings.py inside the alerts project - you'd think the fact that the settings file was in the project folder would be enough. But it complained if I didn't add it explicitly, so I did.
- I cd-ed to djangoprojects/alerts and ran ./manage.py syncdb. It said it synced some stuff, including south and alerts
- Then I ran ./manage.py convert_to_south alerts. This is where I ran into problems. It said: This application has no models; this command is for applications that already have models syncdb'd. Make some models, and then use ./manage.py schemamigration alerts --initial instead.
- So I tried running ./manage.py schemamigration alerts --initial. It created an initial migration but that migration files has almost nothing in it. All it has is a class Migration. None of my real models are anywhere to be found.
- To see if it can recognize any new models, I went to common/models/models.py and added a dummy model. Then I ran ./manage.py schemamigration alerts --auto and the response I got back was "Nothing seems to have changed". So it apperas it still knows nothing about my real models.
Ao at this point I'm totally confused. Like I said, I have an existing database with real data, and I have an existing set of models code that should exactly represent that actual table structure. I just want to start using this in my alerts project and I need south because I will be adding and changing models.
How do I accomplish this?