【问题标题】:django createsuperuser not workingdjango createsuperuser 不工作
【发布时间】:2012-07-20 13:39:03
【问题描述】:

.bash_profile

export PATH="/Applications/MAMP/bin:/usr/local/bin:/usr/local/sbin:usr/local/$
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

export LANG="en_US.UTF-8"

.profile

export PATH="/Applications/MAMP/bin:/usr/local/bin:/usr/local/sbin:usr/local/my$
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
export LANG="en_US.UTF-8"

错误

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle
    default_username = get_default_username()
  File "/Library/Python/2.6/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username
    default_username = get_system_username()
  File "/Library/Python/2.6/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username
    return getpass.getuser().decode(locale.getdefaultlocale()[1])
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py", line 459, in getdefaultlocale
    return _parse_localename(localename)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py", line 391, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

怀疑

我也将我的 LANG 更改为 UTF-8,但我仍然无法解决问题,请帮助

【问题讨论】:

  • 您是否按照 iblazevic 的指示解决了问题?

标签: python django eclipse


【解决方案1】:

您看到这个是因为您的系统上没有设置区域设置。您需要设置它才能创建超级用户,它是已知的并已报告“错误”。

见: https://code.djangoproject.com/ticket/17649

假设您使用的是 linux,您可以使用以下方法修复该错误

export LANG="en_US.UTF-8"

您可以在终端中使用它,但您可以通过谷歌搜索轻松检查并了解如何更改系统上的语言环境。

如果您正在使用:

Ubuntu - https://help.ubuntu.com/community/Locale/

Archlinux - https://wiki.archlinux.org/index.php/Locale

...

【讨论】:

【解决方案2】:

接受的答案对我不起作用,所以我继续四处寻找并找到this。这个对我有用。为了节省时间,我在这里复制粘贴这两行。在终端输入:

$ LC_CTYPE=en_US.UTF-8
$ LC_ALL=en_US.UTF-8

注意:如果相关,我使用 Mac OS 10.7。在系统偏好设置中设置区域设置对我也不起作用。

【讨论】:

  • 这解决了我的问题。你可以通过tracehere找到详细描述
猜你喜欢
  • 2015-07-29
  • 2015-10-04
  • 2015-03-21
  • 2023-01-27
  • 1970-01-01
  • 2021-12-24
  • 1970-01-01
  • 1970-01-01
  • 2020-01-22
相关资源
最近更新 更多