Environment:
Django==1.10.6
wagtail==1.9
After setting up wagtailtinymce as per the instructions in README.md the following happens after trying to run ./manage.py makemigrations (or indeed any other subcommand, I reckon - haven't tested all subcommands).
Here are the last few lines of the stack trace:
File "./venv/local/lib/python2.7/site-packages/wagtailtinymce/rich_text.py", line 66, in __init__
self.kwargs = self.getDefaultArgs()
File "./venv/local/lib/python2.7/site-packages/wagtailtinymce/rich_text.py", line 59, in getDefaultArgs
'language': translation.to_locale(translation.get_language()),
File "./venv/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 202, in to_locale
return _trans.to_locale(language)
File "./venv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 71, in to_locale
p = language.find('-')
AttributeError: 'NoneType' object has no attribute 'find'
After a little investigation, it appears that the language is not set properly in the getDefaultArgs method in class TinyMCERichTextArea in wagtailtinymce/rich_text.py.
To fix, I added an import statement for the project settings before the class is defined:
from django.conf import settings
and then in the definition for getDefaultArgs, I added the following before the return statement:
translation.trans_real.activate(settings.LANGUAGE_CODE)
All seems to work now, but I thought I should share the above and also ask is there a better way to resolve the issue than modifying the source code as above?