kopia lustrzana https://github.com/wagtail/wagtail
Avoid deleting default homepage by ID in home app migration (#13194)
Fixes #4235. It is not safe to assume that the default homepage created in wagtailcore.0002_initial_data will always have the ID 2 on all database configurations, so identify it based on slug, depth and content type instead.pull/13195/head^2
rodzic
65c94448b4
commit
747e76fafa
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue