mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-06 23:38:48 +00:00
- Previous migration needed some tweaking to get it to run... because.. why? - It seems to pass when running manage.py migrate but fails when running manage.py test - Stumped on this one
32 lines
773 B
Python
32 lines
773 B
Python
# Generated by Django 2.2.10 on 2020-04-04 12:38
|
|
|
|
from django.db import migrations
|
|
from django.db.utils import OperationalError
|
|
|
|
from part.models import Part
|
|
from stdimage.utils import render_variations
|
|
|
|
|
|
def create_thumbnails(apps, schema_editor):
|
|
"""
|
|
Create thumbnails for all existing Part images.
|
|
"""
|
|
|
|
try:
|
|
for part in Part.objects.all():
|
|
# Render thumbnail for each existing Part
|
|
if part.image:
|
|
part.image.render_variations()
|
|
except OperationalError:
|
|
print("Error - could not generate Part thumbnails")
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('part', '0033_auto_20200404_0445'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(create_thumbnails),
|
|
]
|