简体   繁体   中英

Django “Table already exists” on testing

I've tried to solve the following issue:
I'm running python manage.py test to test my application.
After creating a new test_app database, I'm getting

DatabaseError: (1050, "Table 'auth_group' already exists")

I haven't installed South (it's not on the INSTALLED_APPS list), how do I solve this?

Install south is the best way for django

You should use south like this if be the first one:

    python manage.py syncdb --settings= SETTINGS_NAME
    python manage.py convert_to_south APP_NAME --settings= SETTINGS_NAME
    python manage.py schemamigration APP_NAME --initial --settings= SETTINGS_NAME
    python manage.py migrate APP_NAME --fake --settings= SETTINGS_NAME

If you made the migrations use the following sentences:

    python manage.py schemamigration APP_NAME --auto
    python manage.py migrate APP_NAME --settings= SETTINGS_NAME)

您应该使用python manage.py migration app_name而不是python manage.py migration。因为您之前使用过

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM