Skip to content

Commit 050b57a

Browse files
committed
fix(wagtail): remove HomeView root route when enabling Wagtail
1 parent afd4535 commit 050b57a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/dbx_python_cli/commands/project.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,12 @@ def _enable_wagtail(project_path: Path, project_name: str) -> None:
10341034

10351035
urls_file = project_path / project_name / "urls.py"
10361036
if urls_file.exists():
1037+
content = urls_file.read_text()
1038+
# Remove the HomeView import and root route — Wagtail's catch-all takes over
1039+
content = content.replace("from .views import HomeView\n", "")
1040+
content = content.replace(
1041+
' path("", HomeView.as_view(), name="default_urlconf"),\n', ""
1042+
)
10371043
wagtail_block = (
10381044
"\n\n# Wagtail CMS\n"
10391045
"from django.conf import settings\n"
@@ -1049,8 +1055,7 @@ def _enable_wagtail(project_path: Path, project_name: str) -> None:
10491055
' path("", include(wagtail_urls)),\n'
10501056
"] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n"
10511057
)
1052-
with open(urls_file, "a") as f:
1053-
f.write(wagtail_block)
1058+
urls_file.write_text(content + wagtail_block)
10541059

10551060

10561061
def _enable_qe(project_path: Path, project_name: str) -> None:

0 commit comments

Comments
 (0)