1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-24 07:19:36 +02:00

new image features

This commit is contained in:
Sean Morley 2024-08-15 19:36:42 -04:00
parent 54d16e27b1
commit 5621e90665
7 changed files with 144 additions and 15 deletions

View file

@ -0,0 +1,29 @@
from django.db import migrations
def move_images_to_new_model(apps, schema_editor):
Adventure = apps.get_model('adventures', 'Adventure')
AdventureImage = apps.get_model('adventures', 'AdventureImage')
for adventure in Adventure.objects.all():
if adventure.image:
AdventureImage.objects.create(
adventure=adventure,
image=adventure.image,
user_id=adventure.user_id,
)
class Migration(migrations.Migration):
dependencies = [
('adventures', '0001_initial'),
('adventures', '0002_adventureimage'),
]
operations = [
migrations.RunPython(move_images_to_new_model),
migrations.RemoveField(
model_name='Adventure',
name='image',
),
]