[Python] Wagtail: requests to the root URL of a multilang website cause error when DEBUG=False

Discussão em 'Python' iniciado por Stack, Julho 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am building a bilingual Wagtail website, following directions in the Wagtail documentation.

    With DEBUG = True in the website settings, all works as expected : one can navigate between english and french versions of the website, and the locale is reflected in the /en/ or /fr/ prefix in the URL. When requesting the root URL of the site https://example.com, the english home page is rendered and the URL has the prefix /en/ added automatically.

    With DEBUG = False, requesting the root URL results in a server error. Adding the /en/ prefix manually still works.

    The (rather long) backtrace of the error is here.

    The website settings are the almost default ones, with additional multi-language configuration:

    MIDDLEWARE = [
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.middleware.locale.LocaleMiddleware",
    "django.middleware.common.CommonMiddleware",
    "django.middleware.csrf.CsrfViewMiddleware",
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "django.contrib.messages.middleware.MessageMiddleware",
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
    "django.middleware.security.SecurityMiddleware",
    "wagtail.contrib.redirects.middleware.RedirectMiddleware",
    ]
    USE_I18N = True
    USE_L10N = True
    WAGTAIL_I18N_ENABLED = True
    USE_TZ = True
    WAGTAILSIMPLETRANSLATION_SYNC_PAGE_TREE = True


    The url configuration is:

    urlpatterns = [
    path("admin/", include(wagtailadmin_urls)),
    path("documents/", include(wagtaildocs_urls)),
    path("search/", search_views.search, name="search"),
    ] + i18n_patterns(
    path('search/', search_views.search, name='search'),
    path("", include(wagtail_urls)),
    )


    If needed, the full website settings are here.

    Note that requesting the admin page at https://example.com/admin causes the same server error when DEBUG = False. Requesting https://example.com/admin/ works though... I tried changing Wagtail versions to v6.4.1 and v7.0.2, but it didn't change anything.

    Continue reading...

Compartilhe esta Página