Asma Gheisari
Asma Gheisari

Reputation: 6254

migrate command in south cause this error:table "model_name" already exist

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

Upvotes: 3

Views: 584

Answers (2)

Neel
Neel

Reputation: 21241

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

Upvotes: 0

Aldarund
Aldarund

Reputation: 17621

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

Upvotes: 3

Related Questions