Search code examples
djangodjango-south

Is it possible to migrate a Django built-in model (eg. auth.user) via a South data migration?


I have to update the auth.user records in a Django app to flip the "is_staff" bit for certain users. I could do this with a SQL script, but it'd be a lot more convenient if I could use a South data migration.

However, whenever I try to do manage.py datamigration auth whatever South creates the migration in lib/python2.7/site-packages/django/contrib/auth/migrations. Does this mean that it's impossible to use South data migrations to migrate user data? Or is there some sort of workaround I'm missing?


Solution

  • Yes this is possible using the SOUTH_MIGRATION_MODULES setting: http://south.readthedocs.org/en/0.7.6/settings.html#south-migration-modules

    A dictionary of alternative migration modules for apps. By default, apps look for their migrations in “.migrations”, but you can override this here, if you have project-specific migrations sets.

    For example

    SOUTH_MIGRATION_MODULES = {
        'auth': 'myproject.migrations.auth',
    }