【发布时间】:2016-04-20 18:25:14
【问题描述】:
我的问题如下:
当我在我的 Django 项目中运行 python manage.py collectstatic 时,我收到了这个错误:
/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py:302: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
return name == ":memory:" or "mode=memory" in force_text(name)
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 151, in handle
message.append(':\n\n %s\n\n' % destination_path)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 32: ordinal not in range(128)
我有点知道,为什么会发生,但我无法适应它。 (也许是因为我不想破坏任何 Django 文件……)
如果您需要更多信息,我很乐意提供给您。
谢谢。
【问题讨论】:
-
您的文件系统路径中有 unicode 字符吗?另外,您使用的是什么版本的 Django?
-
你能把STATIC_ROOT/MEDIA_ROOT的值贴出来吗?
-
@trinchet
STATIC_ROOT = os.path.join(BASE_DIR, 'static')MEDIA_ROOT 未设置! -
还有 BASE_DIR?如果您在运行开发服务器时发布这些 vars 获得的值,那就太好了