Permalink
Browse files

Freeze model in case no migration is defined. Refs #593

  • Loading branch information...
1 parent 3a6213a commit c0ba76962b374837f0a44770e9068e4bde6c71d2 @omab committed Mar 4, 2013
Showing with 10 additions and 4 deletions.
  1. +10 −4 social_auth/utils.py
View
@@ -264,12 +264,18 @@ def custom_user_frozen_models():
'auth.User'
migration_name = getattr(settings, 'INITIAL_CUSTOM_USER_MIGRATION',
'0001_initial.py')
- user_app, user_model = user_model.split('.')
if user_model != 'auth.User':
from south.migration.base import Migrations
- user_migrations = Migrations(user_app)
- initial_user_migration = user_migrations.migration(migration_name)
- extra_model = initial_user_migration.migration_class().models
+ from south.exceptions import NoMigrations
+ from south.creator.freezer import freeze_apps
+ user_app, user_model = user_model.split('.')
+ try:
+ user_migrations = Migrations(user_app)
+ except NoMigrations:
+ extra_model = freeze_apps(user_app)
+ else:
+ initial_user_migration = user_migrations.migration(migration_name)
+ extra_model = initial_user_migration.migration_class().models
else:
extra_model = {}
return extra_model

0 comments on commit c0ba769

Please sign in to comment.