Skip to content

Commit b6cb737

Browse files
authored
Merge pull request #881 from davboecki/patch-1
Fix migration 0014 not working on live data.
2 parents 9c143a4 + 1c512ef commit b6cb737

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

askbot/migrations/0014_populate_askbot_roles.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
def populate_askbot_roles(apps, schema_editor):
1414
Role = apps.get_model('askbot', 'Role')
1515
UserProfile = apps.get_model('askbot', 'UserProfile')
16+
User = apps.get_model('auth', 'User')
1617
profiles = UserProfile.objects.filter(status__in=('m', 'd'))
1718
count = profiles.count()
1819
message = 'Assigning roles {} to the admins and the moderators'
1920
message = message.format(', '.join(MOD_ROLES + ADMIN_ROLES))
2021
for profile in ProgressBar(profiles.iterator(), count, message):
21-
user = profile.auth_user_ptr
22+
user_id = profile.auth_user_ptr_id
23+
user = User.objects.filter(id=user_id)[0]
2224
if profile.status == 'd':
2325
for role in ADMIN_ROLES + MOD_ROLES:
2426
Role.objects.create(user=user, role=role)

0 commit comments

Comments
 (0)