On Heroku locale.getdefaultlocale () returns (None, None), breaking Django creationuperuser - how to fix?

Trying to make heroku python manage.py createsuperuser led to an error that ended up roughly:

 File "/usr/local/www/site-python/lib/django-trunk/django/contrib/auth/management/__init__.py", line 85, in get_system_username return getpass.getuser().decode(locale.getdefaultlocale()[1]) TypeError: decode() argument 1 must be string, not None 

Entering a confirmed shell: locale.getdefaultlocale () returns (None, None) on the Heroku cedar stack. How to set the locale so python takes it?

+4
source share
1 answer

To answer my own question: it turns out, this can be fixed by setting the heroku configuration variable, which leads to an environment variable that python can select, which returns useful values ​​from locale.getdefaultlocale ().

In my case, the heroku parameter that I used was:

 heroku config:add LANG=en_US.UTF-8 

(Of course, other encodings and especially linguistic values ​​may make sense to others.)

The createuperuser problem is fixed and is still so good in everything else. (Other reports show that users running syncdb and choosing to create a superuser then also fall into the same error on some systems.)

Note that any such change triggers a restart of your instance.

+17
source

Source: https://habr.com/ru/post/1392591/


All Articles