Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3.  
  4. from django.db import models, migrations
  5. from django.conf import settings
  6. from django.db.migrations.operations.special import RunPython
  7.  
  8.  
  9. def change_nsn_to_nokia_email(apps, schema_editor):
  10. users = apps.get_model('auth','User')
  11. print users
  12. for user in users.objects.filter(email__endswith='@nsn.com'):
  13. user.email = user.email.split('\@')[0]+'@nokia.com'
  14. user.save()
  15.  
  16. def change_nsn_to_nokia_email_backward(apps, schema_editor):
  17. #raise RuntimeError('Cannot reverse this migration')
  18. pass
  19.  
  20. class Migration(migrations.Migration):
  21. dependencies = [
  22. ('userprofile','0034_manual_correction_20150227')
  23. ]
  24.  
  25. operations = [
  26. RunPython(change_nsn_to_nokia_email, reverse_code=change_nsn_to_nokia_email_backward),
  27. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement