From dbfded9e8600bf1ff2a0554b9e574b976992a85b Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 25 Nov 2014 23:44:20 +0100 Subject: [PATCH] add a migration that creates UserProfile records for all User records --- .../migrations/0002_auto_20141125_2325.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 nsupdate/accounts/migrations/0002_auto_20141125_2325.py diff --git a/nsupdate/accounts/migrations/0002_auto_20141125_2325.py b/nsupdate/accounts/migrations/0002_auto_20141125_2325.py new file mode 100644 index 0000000..35e5743 --- /dev/null +++ b/nsupdate/accounts/migrations/0002_auto_20141125_2325.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from django.contrib.auth import get_user_model + + +def add_userprofiles(apps, schema_editor): + User = get_user_model() + UserProfile = apps.get_model("accounts", "UserProfile") + for user in User.objects.all(): + UserProfile.objects.get_or_create(user=user) + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ] + + operations = [ + migrations.RunPython(add_userprofiles), + ]