Ticket #1274 (closed defect: invalid)

Opened 18 months ago

Last modified 18 months ago

Converting django.contrib.auth to South fails on syncdb

Reported by: Tobias McNulty <tobias@…> Owned by: andrew
Priority: minor Milestone:
Component: migrations Version: unknown
Keywords: Cc:


With the advent of the custom user model in Django, it follows that one might want to use South to clean up (remove) the old auth models after switching an existing project to your custom model of choice.

To accomplish this, I setup migrations for auth to be stored in my project like so:

    'auth': 'myproj.migrations.auth',

and also run:

./manage.py convert_to_south auth

which generated a perfectly acceptable 0001_initial migration for the auth models. Next, I switched AUTH_USER_MODEL to my custom model in settings.py and ran:

./manage.py schemamigration auth --auto

This command also generates a perfectly good 0002 migration to remove the auth_user table and associated many-to-many tables.

However, when I go to syncdb on an *empty* database, something (probably within Django) seems to depend on the existence of the auth models before South can create them (i.e., in the 0001 migration):

$ ./manage.py syncdb --migrate

Creating tables ...
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table south_migrationhistory
DatabaseError: relation "auth_permission" does not exist
LINE 1: ...ntent_type_id", "auth_permission"."codename" FROM "auth_perm...

I'm not sure there's any reason to support this because it's probably not that common of an issue, but I thought I'd document it nonetheless in case anyone else tries to add django.contrib.auth (or other django contrib apps like sites or contenttypes) to SOUTH_MIGRATION_MODULES.

A workaround if you run into this is to create the 0002 migration like I did above (using a temporary auth migrations module) and then move it out of the auth migrations module and into your custom user app migrations module.

Change History

comment:1 Changed 18 months ago by andrew

  • Status changed from new to closed
  • Resolution set to invalid

South is not meant to make migrations for Django's contrib apps, they're not designed to work with it.

Note: See TracTickets for help on using tickets.