English 中文(简体)
PyDev 中的Django Sync DB (剪贴和Aptana) 在回答“是”定义超级用户后失败 [已关闭]
原标题:Django Sync DB in PyDev (Eclipse and Aptana) fails after answering "yes" to define superusers [closed]

这里可能发生了什么?这是我的两个不同的Macs的问题—— 一个Eclipse安装和一个Aptana工作室。我第一次同步 DB 时回答“是 ” 创建超级用户后, 我就会得到这些错误。

PyDev (通过终端等) 外的表演同步 db 似乎效果良好 。

You just installed Django s auth system, which means you don t have any superusers defined. Would you like to create one now? (yes/no): yes Traceback (most recent call last): File "/Users/mac2/Documents/workspace/helloworld/manage.py", line 10, in execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/init.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(*args, **options.dict) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle return self.handle_noargs(**options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs emit_post_sync_signal(created_models, verbosity, interactive, db) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal interactive=interactive, db=db) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send response = receiver(signal=self, sender=sender, **named) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/init.py", line 73, in create_superuser call_command("createsuperuser", interactive=True, database=db) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/init.py", line 150, in call_command return klass.execute(*args, **defaults) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle default_username = get_default_username() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/init.py", line 105, in get_default_username default_username = get_system_username() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/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 Finished "/Users/mac2/Documents/workspace/helloworld/manage.py syncdb" execution.

最佳回答

错误返回时显示,调用 decode 的电话失败,没有参数:

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/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 Finished

问题在于 locale.getdefaultlocale () 返回环境变量 LANG (见http://docs.python.org/library/locale.html )。 如果您打开终端, 在那里同步工作, 并且输入 echo $LANG , 我猜测你会得到类似 en_US.UTF-8 的东西。 同样, 我想象您命令行上的 Python 会返回类似的东西 :

>>> import locale
>>> locale.getdefaultlocale()
( en_US ,  UTF-8 )

然而,如果您在不设置 LANG 环境变量的剪贴板内执行相同的命令,您可获得 < code> (None, None) 。

尝试在 Eclipse 中设置 LANG 环境变量( 运行配置... & gt; 环境), 然后运行同步 。 您可能需要在变量设定的位置( 即运行配置相对于工程本身) 中玩一下 。 这样可以解决问题吗?

问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签