From 3b51546fced5f71793c0de5b9eb5098e2c386d9e Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 19 Jun 2022 11:36:15 +0100 Subject: [PATCH] Ensure hero images are optional --- .../0003_alter_contentpage_hero_image.py | 25 +++++++++++++++++++ website/common/models.py | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 website/common/migrations/0003_alter_contentpage_hero_image.py diff --git a/website/common/migrations/0003_alter_contentpage_hero_image.py b/website/common/migrations/0003_alter_contentpage_hero_image.py new file mode 100644 index 0000000..54ff8f8 --- /dev/null +++ b/website/common/migrations/0003_alter_contentpage_hero_image.py @@ -0,0 +1,25 @@ +# Generated by Django 4.0.5 on 2022-06-19 10:35 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("wagtailimages", "0024_index_image_file_hash"), + ("common", "0002_contentpage_hero_image"), + ] + + operations = [ + migrations.AlterField( + model_name="contentpage", + name="hero_image", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="wagtailimages.image", + ), + ), + ] diff --git a/website/common/models.py b/website/common/models.py index 88231de..19ec8f9 100644 --- a/website/common/models.py +++ b/website/common/models.py @@ -21,7 +21,7 @@ class BasePage(Page): class ContentPage(BasePage): subtitle = models.CharField(max_length=255, blank=True) hero_image = models.ForeignKey( - get_image_model_string(), null=True, on_delete=models.SET_NULL + get_image_model_string(), null=True, blank=True, on_delete=models.SET_NULL ) content_panels = BasePage.content_panels + [