1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
4 from django.db import models, migrations
6 def rebuild_extra_info(apps, schema_editor):
7 Picture = apps.get_model("picture", "Picture")
8 from librarian.picture import PictureInfo
9 from librarian import dcparser
10 for pic in Picture.objects.all():
11 info = dcparser.parse(pic.xml_file.path, PictureInfo)
12 pic.extra_info = info.to_dict()
16 class Migration(migrations.Migration):
19 ('picture', '0004_auto_20141016_1337'),
23 migrations.RunPython(rebuild_extra_info),