diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 43d623ecde..48e3e32720 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -50,6 +50,7 @@ * Fix: Remove ngram parser on MySQL that prevented autocomplete search from returning results (Vince Salvino) * Fix: Only enable ManifestStaticFilesStorage in production settings, to aid test running (M. Sumair Khokhar) * Fix: Update `BooleanColumn` icons so they can be distinguished without relying on color (Sage Abdullah) + * Fix: Do not delete default homepage by ID in home app migration (Matt Westcott) * Docs: Add missing tag library imports to footer template code in tutorial (Dimaco) * Docs: Improve documentation around securing user-uploaded files (Jake Howard) * Docs: Introduce search_fields in a dedicated tutorial section instead of the introduction (Matt Westcott) diff --git a/docs/releases/7.1.md b/docs/releases/7.1.md index 796f3c6842..e25a821e48 100644 --- a/docs/releases/7.1.md +++ b/docs/releases/7.1.md @@ -65,6 +65,7 @@ The [](../reference/contrib/settings) app now allows permission over site settin * Remove ngram parser on MySQL that prevented autocomplete search from returning results (Vince Salvino) * Only enable ManifestStaticFilesStorage in production settings, to aid test running (M. Sumair Khokhar) * Update `BooleanColumn` icons so they can be distinguished without relying on color (Sage Abdullah) + * Do not delete default homepage by ID in home app migration (Matt Westcott) ### Documentation diff --git a/wagtail/project_template/home/migrations/0002_create_homepage.py b/wagtail/project_template/home/migrations/0002_create_homepage.py index e84576f42d..a3e918ec54 100644 --- a/wagtail/project_template/home/migrations/0002_create_homepage.py +++ b/wagtail/project_template/home/migrations/0002_create_homepage.py @@ -8,9 +8,14 @@ def create_homepage(apps, schema_editor): Site = apps.get_model("wagtailcore.Site") HomePage = apps.get_model("home.HomePage") - # Delete the default homepage - # If migration is run multiple times, it may have already been deleted - Page.objects.filter(id=2).delete() + # Delete the default homepage (of type Page) as created by wagtailcore.0002_initial_data, + # if it exists + page_content_type = ContentType.objects.get( + model="page", app_label="wagtailcore" + ) + Page.objects.filter( + content_type=page_content_type, slug="home", depth=2 + ).delete() # Create content type for homepage model homepage_content_type, __ = ContentType.objects.get_or_create(