From bb50af109956d6041455dc086feded8405e89186 Mon Sep 17 00:00:00 2001 From: Michael Volo Date: Thu, 25 Jul 2024 10:27:36 -0500 Subject: [PATCH] allow default promote image if not set (#1572) --- .../0137_alter_rootpage_promote_image.py | 26 +++++++++++++++++++ pages/models.py | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 pages/migrations/0137_alter_rootpage_promote_image.py diff --git a/pages/migrations/0137_alter_rootpage_promote_image.py b/pages/migrations/0137_alter_rootpage_promote_image.py new file mode 100644 index 000000000..c14ecb883 --- /dev/null +++ b/pages/migrations/0137_alter_rootpage_promote_image.py @@ -0,0 +1,26 @@ +# Generated by Django 5.0.7 on 2024-07-25 02:04 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("pages", "0136_alter_rootpage_layout"), + ("wagtailimages", "0025_alter_image_file_alter_rendition_file"), + ] + + operations = [ + migrations.AlterField( + model_name="rootpage", + name="promote_image", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="+", + to="wagtailimages.image", + ), + ), + ] diff --git a/pages/models.py b/pages/models.py index 573f10c88..2d452c8c8 100644 --- a/pages/models.py +++ b/pages/models.py @@ -147,7 +147,7 @@ class RootPage(Page): promote_image = models.ForeignKey( 'wagtailimages.Image', null=True, - blank=False, + blank=True, on_delete=models.SET_NULL, related_name='+' )