X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/52d79280796679d28fb526063c77c43851ae52c4..c06d9009a2f0caff4557384179078b4e45edfb8d:/src/cover/migrations/0004_populate_use_file.py diff --git a/src/cover/migrations/0004_populate_use_file.py b/src/cover/migrations/0004_populate_use_file.py new file mode 100644 index 00000000..0ae52956 --- /dev/null +++ b/src/cover/migrations/0004_populate_use_file.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.13 on 2022-02-25 14:31 + +from django.db import migrations + + +def populate_use_file(apps, schema_editor): + Image = apps.get_model('cover', 'Image') + for img in Image.objects.all(): + img.use_file.save( + "%d.jpg" % img.id, + img.file + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('cover', '0003_auto_20220225_1431'), + ] + + operations = [ + migrations.RunPython( + populate_use_file, + migrations.RunPython.noop + ) + ]