Compare commits
13 commits
ae1ad6965f
...
737f073287
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
737f073287 | ||
|
|
87fbcdc013 | ||
|
|
8cda627753 | ||
|
|
69a4a3ca9d | ||
|
|
64f3b0cdbf | ||
|
|
a41dfb6f94 | ||
|
|
320411fd18 | ||
|
|
9cc99a0d13 | ||
|
|
836e0b2cd0 | ||
|
|
116614a620 | ||
|
|
3e1920cb84 | ||
|
|
9a63dea0cb | ||
|
|
981c2c37c0 |
1 changed files with 31 additions and 0 deletions
31
photologue/migrations/0009_regen_thumbnails.py
Normal file
31
photologue/migrations/0009_regen_thumbnails.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def regen_thumbnails(apps, schema_editor):
|
||||||
|
Photo = apps.get_model("photologue", "Photo")
|
||||||
|
PhotoSize = apps.get_model("photologue", "PhotoSize")
|
||||||
|
|
||||||
|
try:
|
||||||
|
thumbnail = PhotoSize.objects.get(name="thumbnail")
|
||||||
|
except PhotoSize.DoesNotExist:
|
||||||
|
return
|
||||||
|
|
||||||
|
for photo in Photo.objects.all():
|
||||||
|
# Use the real model instance to access file methods
|
||||||
|
from photologue.models import Photo as RealPhoto
|
||||||
|
try:
|
||||||
|
real_photo = RealPhoto.objects.get(pk=photo.pk)
|
||||||
|
real_photo.remove_size(thumbnail)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("photologue", "0008_photo_dimensions"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(regen_thumbnails, migrations.RunPython.noop),
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue