Skip to content

Commit a655534

Browse files
committed
fix: remove home app from Wagtail template to resolve InvalidBasesError
The home app (HomePage extending wagtail.models.Page) caused a Django InvalidBasesError during migrate because the home app used syncdb while wagtailcore participates in the migration framework. Removing the app avoids the conflict; the initial Wagtail root/home pages are now created using plain Page instances. The base Django HomeView is unaffected.
1 parent 74b3d45 commit a655534

5 files changed

Lines changed: 1 addition & 28 deletions

File tree

src/dbx_python_cli/commands/project.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ def _setup_wagtail_initial_data(
939939
0001 migration normally creates the root Page and a default Site; without
940940
them the admin home view cannot build the 'wagtailadmin_explore' URL.
941941
"""
942-
proj_name = proj.name
943942
script_lines = [
944943
"import sys, django",
945944
"try:",
@@ -949,13 +948,11 @@ def _setup_wagtail_initial_data(
949948
" from django.conf import settings as _s",
950949
" from django.contrib.contenttypes.models import ContentType",
951950
" from wagtail.models import Locale, Site",
952-
f" from {proj_name}.home.models import HomePage",
953951
" lang = (getattr(_s, 'LANGUAGE_CODE', 'en') or 'en').split('-')[0][:2]",
954952
" locale, _ = Locale.objects.get_or_create(language_code=lang)",
955953
" page_ct, _ = ContentType.objects.get_or_create(app_label='wagtailcore', model='page')",
956-
" home_ct, _ = ContentType.objects.get_or_create(app_label='home', model='homepage')",
957954
" root = Page.add_root(title='Root', slug='root', content_type=page_ct, locale=locale)",
958-
" home = root.add_child(instance=HomePage(title='Home', slug='home', content_type=home_ct, locale=locale))",
955+
" home = root.add_child(instance=Page(title='Home', slug='home', content_type=page_ct, locale=locale))",
959956
" print('wagtail_root_created')",
960957
" if not Site.objects.exists():",
961958
" Site.objects.create(hostname='localhost', root_page=home, is_default_site=True)",

src/dbx_python_cli/templates/project_template/project_name/home/__init__.py

Whitespace-only changes.

src/dbx_python_cli/templates/project_template/project_name/home/apps.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/dbx_python_cli/templates/project_template/project_name/home/models.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/dbx_python_cli/templates/project_template/project_name/settings/wagtail.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"wagtail.sites",
2525
"modelcluster",
2626
"{{ project_name }}.settings.apps.wagtail.CustomTaggitConfig",
27-
"{{ project_name }}.home.apps.HomeAppConfig",
2827
]
2928

3029
WAGTAIL_MIDDLEWARE = [
@@ -51,10 +50,4 @@
5150
"wagtailforms": "{{ project_name }}.migrations.wagtailforms",
5251
"wagtailusers": "{{ project_name }}.migrations.wagtailusers",
5352
"taggit": "{{ project_name }}.migrations.taggit",
54-
# home uses syncdb (None) for the same reason all Wagtail apps above use
55-
# empty migration directories: wagtailcore itself has no recorded migrations,
56-
# so any app inheriting from Page cannot express a valid migration dependency
57-
# on it. MongoDB auto-creates collections on first insert, so no migration
58-
# file is needed.
59-
"home": None,
6053
}

0 commit comments

Comments
 (0)