3

I have a project named HubHub that contains 2 apps named DrHub and AgencyHub,when changing models syncdb doesn't change them and I tried to use south : in settings.py:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'grappelli',
    'django.contrib.admin',
    'south',
    'AgencyHub',
    'DrHub',
)

I ran the first command to config first migration based on this tutorial: http://south.aeracode.org/docs/tutorial/part1.html

python manage.py schemamigration DrHub --initial

and the second command:

python manage.py migrate DrHub

but this command cause this error:

table "model_name" already exist

"model_name" is the name of first model of models.py in DrHub

If you found any solution then post answer.

thanks in advance

Nilesh
  • 20,521
  • 16
  • 92
  • 148
Asma Gheisari
  • 5,794
  • 9
  • 30
  • 51

2 Answers2

3

It`s because initial migration will create all tables in database for you. And you have an existing database with existing tables. You can either wipe you database and then do a migrate or you need to use a --fake option in migrate. Docs here

python manage.py migrate DrHub --fake
Aldarund
  • 17,312
  • 5
  • 73
  • 104
  • I removed database file and tryed again,but migrate command caused this error:no such table: south_ migrationhistory – Asma Gheisari Feb 20 '12 at 09:30
  • 1
    If you removed the database then you don`t need to use a --fake key. Just run syncdb and then migrate and it will work fine. – Aldarund Feb 20 '12 at 09:34
  • You need to run syncdb first. And only after syncdb you should run migrate. Syncdb will create south_ migrationhistory and after it you can run migrate. – Aldarund Feb 20 '12 at 09:40
  • tnx,your're right and of course your answer directed me to this greate page: http://stackoverflow.com/questions/5687627/django-south-error-with-initial-migration – Asma Gheisari Feb 20 '12 at 10:11
0

Please remove the database table and try to create sync db.

Nilesh
  • 20,521
  • 16
  • 92
  • 148