Skip to content

Instantly share code, notes, and snippets.

@wjdp
Created November 9, 2014 20:31
Show Gist options
  • Save wjdp/e6163dc7e18120709fa6 to your computer and use it in GitHub Desktop.
Save wjdp/e6163dc7e18120709fa6 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def copy_users(apps, schema_editor):
User = apps.get_model('auth','User')
XSDUser = apps.get_model('xsd_auth','XSDUser')
for old_user in User.objects.all():
new_user = XSDUser()
new_user.pk = old_user.pk
new_user.username = old_user.username
new_user.email = old_user.email
new_user.password = old_user.password
new_user.first_name = old_user.first_name
new_user.last_name = old_user.last_name
new_user.is_staff = old_user.is_staff
new_user.is_active = old_user.is_active
new_user.date_joined = old_user.date_joined
class Migration(migrations.Migration):
dependencies = [
('xsd_auth', '0001_initial'),
]
operations = [
migrations.RunPython(copy_users),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment