# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-27 09:56 from __future__ import unicode_literals from django.db import migrations from django.db.models import Q from django.db import models from boards.utils import get_file_mimetype class Migration(migrations.Migration): def extension_to_mimetype(apps, schema_editor): Attachment = apps.get_model('boards', 'Attachment') for attachment in Attachment.objects.filter(Q(url='') | Q(url=None)): attachment.mimetype = get_file_mimetype(attachment.file) attachment.save(update_fields=['mimetype']) attachment.file.close() dependencies = [ ('boards', '0058_auto_20170224_2310'), ] operations = [ migrations.AlterField( model_name='attachment', name='mimetype', field=models.CharField(max_length=200, null=True), ), migrations.RunPython(extension_to_mimetype), ]