pulseapi/creators/migrations/0007_auto_20171004_1634.py (19 lines of code) (raw):
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-10-04 16:34
from __future__ import unicode_literals
from django.db import migrations
def set_profile_from_user(apps, schema_editor):
"""
Sets the profile property for a creator for those creators
that have users.
"""
Creator = apps.get_model('creators', 'Creator')
creators_with_users = Creator.objects.filter(
user__isnull=False
).select_related('user')
for creator in creators_with_users:
user = creator.user
creator.profile = user.profile
creator.save()
class Migration(migrations.Migration):
dependencies = [
('creators', '0006_creator_profile'),
('users', '0008_auto_20170929_1812'),
]
operations = [
migrations.RunPython(set_profile_from_user)
]