2 from django.db import migrations
5 def populate_completed_at(apps, schema_editor):
6 PayUOrder = apps.get_model('club', 'PayUOrder')
7 for order in PayUOrder.objects.filter(status='COMPLETED'):
8 for n in order.notification_set.order_by('received_at'):
9 if json.loads(n.body)['order']['status'] == 'COMPLETED':
10 order.completed_at = n.received_at
15 class Migration(migrations.Migration):
18 ('club', '0022_payuorder_completed_at'),
23 populate_completed_at,
24 migrations.RunPython.noop,