Django behavior on translatable URL patterns (i18n_patterns) when prefix_default_language=False is used.

I knew I’d seen this before somewhere :sweat_smile:

From: #29425 (Auto language redirect does not work if prefix_default_language=False in root URLConf) – Django

​Explanation from PR 6264, which added the extra test and behaviour:

The redirect should only happen on / URL, with prefix_default_language set to True (default behaviour).

Each other request (like /fr/whatever/) should not look at Accept-Language header at all,
just serve the page for the language requested in URL.

When the prefix_default_language is False the / url is the same as /en/
(with settings.LANGUAGE_CODE=en) so we should just ignore the Accept-Language here.

1 Like