When editing a page in language that is not set to Live, including a Language selector will break Preview of that page .
The root of the problem seems to be in the code that renders language selector.
How to reproduce?
WAGTAILTRANS_SYNC_TREE=False
Add a new Language (say, Spanish) to the site. Keep its "Live" flag off.
Given a page class A, make sure that the template of A that includes a Language selector ({% render_language_selector page %})
Create a page "New Page" of class A in canonical language
Translate this "New Page" to Spanish.
When the page editor opens, press "Preview" button.
Expected result:
The preview opens as usual, but Spanish language is not in the list of languages in Language selector.
Actual result:
The page rendering fails with ValueError: list.remove(x): x not in list
Issue summary
When editing a page in language that is not set to Live, including a Language selector will break Preview of that page . The root of the problem seems to be in the code that renders language selector.
How to reproduce?
WAGTAILTRANS_SYNC_TREE=False
{% render_language_selector page %}
)Expected result: The preview opens as usual, but Spanish language is not in the list of languages in Language selector.
Actual result: The page rendering fails with
ValueError: list.remove(x): x not in list
Technical details