Commits

Anonymous committed 7f6a128

Backwards compatible for django < 1.5.

  • Participants
  • Parent commits 1fa4210
  • Branches fix_migrations_for_custom_user_model

Comments (0)

Files changed (2)

admin_tools/dashboard/migrations/0001_initial.py

 from south.v2 import SchemaMigration
 from django.db import models
 from django.conf import settings
-from django.contrib.auth import get_user_model
 from south import modelsinspector
 
+try:
+    from django.contrib.auth import get_user_model
+    UserModel = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User as UserModel
+
+
 user_model = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
 
 
 class Migration(SchemaMigration):
 
     def forwards(self, orm):
-        
+
         # Adding model 'DashboardPreferences'
         db.create_table('admin_tools_dashboard_preferences', (
             ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
 
 
     def backwards(self, orm):
-        
+
         # Deleting model 'DashboardPreferences'
         db.delete_table('admin_tools_dashboard_preferences')
 
             'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
         },
         user_model: {
-            'Meta': modelsinspector.get_model_meta(get_user_model()),
+            'Meta': modelsinspector.get_model_meta(UserModel),
             'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
             'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
             'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),

admin_tools/menu/migrations/0001_initial.py

 from django.db import models
 from django.conf import settings
 from south import modelsinspector
-from django.contrib.auth import get_user_model
+
+try:
+    from django.contrib.auth import get_user_model
+    UserModel = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User as UserModel
+
 
 user_model = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
 
             'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
         },
         user_model: {
-            'Meta': modelsinspector.get_model_meta(get_user_model()),
+            'Meta': modelsinspector.get_model_meta(UserModel),
             'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
             'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
             'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),