1👍
Of course its going to be like this, you have not made any intial schemamigrations. The right way would be like this:
- Register your django apps with
south
first. So something like:python manage.py schemamigration --initial <app_name>
. - Then you run
manage.py syncdb
. - After this, you run
migrate
like sopython manage.py migrate <apps>
, please note that simply runningmigrate
will just migrate all your registered apps. I tend to do this. - If you change models to change the schema, then you can simply use:
manage.py schemamigration --auto
The problem that you are alluding to is this. Once you run syncdb
, you already get a table crated, south had nothing to do with this. What you are hence doing is querying a database that has no migration control (iirc).
- [Django]-Location widget in messenger platform displays a search bar in mobile version but not in Desktop Version
- [Django]-Bin/python3: cannot execute binary file: Exec format error
1👍
It’s a bad practice to issue python manage.py syncdb; python manage.py migrate --all
for the first time. First of all, I won’t trust much in --all
option. It may include Django’s oficial libraries and you certainly don’t want that, even when There’s nothing to migrate in them. I rather go by python manage.py migrate <app_name1> <app_name2> ...
But for what South concerns, the way of using South is:
- Create an app
- Create a migration for it with
python manage.py schemamigration --initial <app>
- Convert to south and exising migration with
python manage.py convert_to_south <app> --auto
- Do some modifications to the app and then
python manage.py migrate <app>
Your approach might actually work, but take into account that when you do migrate --all
you don’t controll the order of migrations applied, and python manage.py syncdb
won’t assure the contentType
your accessing is (myapp, mymodel) available at that time.
The error is appearing only first time because maybe the migration is actually being applied once. And getting save in the south_migrationhistory
table as already applied, so when you issue the command again, it ignores it.
My advice, migrate first the target apps, after the syncdb
command. If this doesn’t work or things get messy, try this:
- Comment the line
'south',
inINSTALLED_APPS
- Issue
python manage.py syncdb
- Remove comment from line
#'south',
inINSTALLED_APPS
- Issue the final command
python manage.py migrate --all
Good luck, hope this helps!
- [Django]-Most_common with django-taggit
- [Django]-Passing a cv2 frame from view to template
- [Django]-Running Django 1.5 and Django 1.3 on the same server
- [Django]-Django Queryset Iterator for Ordered queryset