0003_3_user_foreign_keys.py 688 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-10-12 09:59
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


def forward_func(apps, schema_editor):
    Order = apps.get_model('pizzas', 'Order')

    for order in Order.objects.all():
        if order.member_old:
            order.member = order.member_old.user
            order.save(update_fields=('member',))


class Migration(migrations.Migration):

    dependencies = [
        ('pizzas', '0003_2_user_foreign_keys'),
    ]

    operations = [
        migrations.RunPython(
            code=forward_func,
        ),
    ]