diff --git a/fluent_pages/management/commands/rebuild_page_tree.py b/fluent_pages/management/commands/rebuild_page_tree.py index a71b952d..961b0bbe 100644 --- a/fluent_pages/management/commands/rebuild_page_tree.py +++ b/fluent_pages/management/commands/rebuild_page_tree.py @@ -101,7 +101,7 @@ def handle_noargs(self, **options): ))) def _construct_url(self, language_code, child_id, parents, slugs, overrides): - fallback = appsettings.FLUENT_PAGES_LANGUAGES.get_fallback_language(language_code) + active_choices = appsettings.FLUENT_PAGES_LANGUAGES.get_active_choices(language_code) breadcrumb = [] cur = child_id @@ -119,9 +119,13 @@ def _construct_url(self, language_code, child_id, parents, slugs, overrides): continue except KeyError: pass - try: - url_parts.append(slugs[language_code][id]) - except KeyError: - url_parts.append(slugs[fallback][id]) + + # Add first one found, preferably the normal language, fallback otherwise. + for lang in active_choices: + try: + url_parts.append(slugs[lang][id]) + break + except KeyError: + continue return (u'/'.join(url_parts) + u'/').replace('//', '/')