Trying to do a heroku python manage.py createsuperuser
gave me an error that ended 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 shell confirmed: locale.getdefaultlocale() is returning (None, None) on my Heroku Cedar stack. How do I set the locale such that python picks it up?
To answer my own question: it turns out this can be fixed by the setting a heroku configuration variable, which results in an environment variable that python can pick up, which returns usable values from locale.getdefaultlocale().
In my case the heroku setting I used was:
heroku config:add LANG=en_US.UTF-8
(Of course other encoding and especially language values might make sense for others.)
It fixed the createsuperuser issue and so far so good on everything else. (Other reports suggest users doing a syncdb and choosing to create a superuser then have also hit this same error on some systems.)
Note that any such change triggers a restart of your instance(s).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With