1 # Generated by Django 3.0.4 on 2020-05-24 01:40
4 from django.db import migrations
7 def populate_license(apps, schema_editor):
8 License = apps.get_model('archive.License')
9 Audiobook = apps.get_model('archive.Audiobook')
11 for a in Audiobook.objects.all():
13 tags = json.loads(a.mp3_tags)
14 uri = tags.get('license')
17 if uri not in licenses:
18 licenses[uri], created = License.objects.get_or_create(uri=uri, defaults={"name": "?"})
19 a.license = licenses[uri]
23 class Migration(migrations.Migration):
26 ('archive', '0009_auto_20200524_0139'),
32 migrations.RunPython.noop