You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initial migrations fail on Wagtail 2.11.1 with USE_I18N = False and LANGUAGE_CODE = 'en-us' in settings.
Steps to Reproduce
Start a new project with wagtail start myproject
Edit myproject/settings/base.py and set USE_I18N = False
Run ./manage.py migrate
This throws the exception:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 92, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py", line 53, in __init__
self.build_graph()
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py", line 210, in build_graph
self.load_disk()
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py", line 112, in load_disk
migration_module = import_module(migration_path)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/migrations/0056_page_locale_fields_populate.py", line 8, in <module>
class Migration(migrations.Migration):
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/migrations/0056_page_locale_fields_populate.py", line 15, in Migration
BootstrapTranslatableModel('wagtailcore.Page'),
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/models.py", line 538, in __init__
language_code = get_supported_content_language_variant(settings.LANGUAGE_CODE)
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/utils.py", line 261, in get_supported_content_language_variant
supported_lang_codes = get_content_languages()
File "/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/utils.py", line 224, in get_content_languages
(default_language_code, languages[default_language_code]),
KeyError: 'en-us'
This seems to happen because with USE_I18N = False, the implementation of get_supported_language_variant in Django's 'null' i18n backend returns LANGUAGE_CODE unchanged, whereas the real one takes fallbacks into account (returning 'en' for 'en-us'). Wagtail's get_content_languages then expects to find this in settings.LANGUAGES, which fails because Django's master LANGUAGES list contains 'en', not 'en-us'.
I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes
Technical details
Python version: 3.7.2
Django version: 3.1.3
Wagtail version: 2.11.1
The text was updated successfully, but these errors were encountered:
…t in LANGUAGES (#6547)
* Handle get_supported_language_variant returning a language variant not in LANGUAGES
Fixes#6539
* Handle LANGUAGE_CODE that isn't in LANGUAGES
* Release note for #6547
…t in LANGUAGES (#6547)
* Handle get_supported_language_variant returning a language variant not in LANGUAGES
Fixes#6539
* Handle LANGUAGE_CODE that isn't in LANGUAGES
* Release note for #6547
Issue Summary
Initial migrations fail on Wagtail 2.11.1 with USE_I18N = False and LANGUAGE_CODE = 'en-us' in settings.
Steps to Reproduce
wagtail start myproject
myproject/settings/base.py
and setUSE_I18N = False
./manage.py migrate
This throws the exception:
This seems to happen because with USE_I18N = False, the implementation of
get_supported_language_variant
in Django's 'null' i18n backend returns LANGUAGE_CODE unchanged, whereas the real one takes fallbacks into account (returning 'en' for 'en-us'). Wagtail'sget_content_languages
then expects to find this in settings.LANGUAGES, which fails because Django's master LANGUAGES list contains 'en', not 'en-us'.Technical details
The text was updated successfully, but these errors were encountered: