From a1f00a0025c90809640f30cf083644be87c56c30 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Mon, 15 Jun 2026 12:11:48 +0200 Subject: [PATCH] fix: route the CMS catch-all through i18n_patterns `djangocms .` inserts `path("", include("cms.urls"))` into urls.py when adding django CMS to an existing project. It was always appended to the plain `urlpatterns` list, which strips the language prefix from CMS pages and contradicts the documented manual installation. Mark the CMS catch-all rule with `"i18n": true` so the installer routes it through `i18n_patterns()` when the project's urls.py already uses i18n_patterns (otherwise it stays in the plain list). Document the flag in the rules comment and add it to the JSON schema's urlRule (which uses additionalProperties: false, so the property must be declared). Co-Authored-By: Claude Opus 4.8 (1M context) --- djangocms_install_rules.json | 4 ++-- djangocms_install_rules.schema.v1.json | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/djangocms_install_rules.json b/djangocms_install_rules.json index 3d3c0bc..713c1db 100644 --- a/djangocms_install_rules.json +++ b/djangocms_install_rules.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/django-cms/cms-template/main/djangocms_install_rules.schema.v1.json", - "comment": "Rules used by `djangocms .` to add django CMS to an existing project. Fetched from the cms-template repository (branch matching the installed django CMS major.minor), with this file as the bundled fallback. Each `when` condition may contain a `flag` (truthy command option) and/or a `mode` (list of matching --mode values). For installed_apps and middleware a rule may also carry a `before` or `after` anchor (an existing entry) for positional insertion; otherwise items are appended.", + "comment": "Rules used by `djangocms .` to add django CMS to an existing project. Fetched from the cms-template repository (branch matching the installed django CMS major.minor), with this file as the bundled fallback. Each `when` condition may contain a `flag` (truthy command option) and/or a `mode` (list of matching --mode values). For installed_apps and middleware a rule may also carry a `before` or `after` anchor (an existing entry) for positional insertion; otherwise items are appended. A url rule may carry `\"i18n\": true` to route its pattern through `i18n_patterns()` (so the CMS catch-all keeps its language prefix) when the project's urls.py already uses i18n_patterns; otherwise the pattern is added to the plain urlpatterns list.", "installed_apps": [ {"items": ["djangocms_simple_admin_style"], "before": "django.contrib.admin"}, { @@ -72,7 +72,7 @@ "urls": [ {"pattern": "path(\"api/\", include(\"djangocms_rest.urls\"))", "when": {"mode": ["headless", "hybrid"]}}, {"pattern": "path(\"taggit_autosuggest/\", include(\"taggit_autosuggest.urls\"))", "when": {"flag": "stories"}}, - {"pattern": "path(\"\", include(\"cms.urls\"))", "when": {"mode": ["traditional", "hybrid"]}} + {"pattern": "path(\"\", include(\"cms.urls\"))", "i18n": true, "when": {"mode": ["traditional", "hybrid"]}} ], "packages": { "filer": "django-filer" diff --git a/djangocms_install_rules.schema.v1.json b/djangocms_install_rules.schema.v1.json index d0a267e..1e7e23d 100644 --- a/djangocms_install_rules.schema.v1.json +++ b/djangocms_install_rules.schema.v1.json @@ -208,6 +208,10 @@ "type": "string", "description": "Python expression for the URL pattern, e.g. path(\"\", include(\"cms.urls\"))." }, + "i18n": { + "type": "boolean", + "description": "Route this pattern through i18n_patterns() (so it keeps a language prefix) when the project's urls.py already uses i18n_patterns; otherwise it is added to the plain urlpatterns list. Used for the CMS catch-all." + }, "when": { "$ref": "#/definitions/when" },