Django的:执行命令collectstatic统一筹集codeDE codeError [英] Django : execute command collectstatic raise UnicodeDecodeError

查看:1455
本文介绍了Django的:执行命令collectstatic统一筹集codeDE codeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么统一筹集codeDE codeError?
我尝试部署Django应用程序使用Apache我
复制静态文件,键入

Why raise UnicodeDecodeError? I try to deploy my django app using apache to copy static files, typing

$python manage.py collectstatic

和我有错误消息像下面。

and I got error message like below.

You have requested to collect static files at the destination
location as specified in your settings.

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 163, in handle_noargs
collected = self.collect()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 104, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/finders.py", line 137, in list
for path in utils.get_files(storage, ignore_patterns):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/utils.py", line 37, in get_files
for fn in get_files(storage, ignore_patterns, dir):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/utils.py", line 37, in get_files
for fn in get_files(storage, ignore_patterns, dir):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/utils.py", line 25, in get_files
directories, files = storage.listdir(location)
File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py", line 236, in listdir
if os.path.isdir(os.path.join(path, entry)):
File "/usr/lib/python2.7/posixpath.py", line 71, in join
path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xba in position 1: ordinal not in range(128)

这有什么错我的静态文件?
我的settings.py

What's wrong with my static files? my settings.py

import os
PROJECT_ROOT = os.path.dirname(__file__)
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static/')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'


STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

和apache的主机的conf

and apache host conf

ServerName www.abcd.org
DocumentRoot /srv/www/yyy

<Directory /srv/www/yyy>
    Order allow,deny 
    Allow from all 
</Directory>

WSGIDaemonProcess yyy.djangoserver processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup iii.djangoserver

WSGIScriptAlias / /srv/www/yyy/apache/django.wsgi

推荐答案

看起来像一个或多个路径,以静态文件将要复制包含非ASCII字符。

Looks like one or more paths to your static files that are going to be copied contains non ASCII characters.

它无关的路径desctination目录。

It has nothing to do with the path to the desctination directory.

找出一种方法是

try:
    print path
except:
    pass
try:
    print entry
except:
    pass  

刚刚在/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py线236片刻前,然后再次运行manage.py。

just before line 236 in /usr/local/lib/python2.7/dist-packages/django/core/files/storage.py for a moment and then run manage.py again.

然后,你应该看到问题出现时(你不会看到很罪魁祸首,但只是面前的文件和文件问题的propably目录)。

Then you should see where the problem occurs (you won't see the very culprit but the file just before it and propably directory of the problematic file).

或,或者,你可以使用PDB

python -m pdb manage.py collectstatic

和检查哪些文件在调试器导致的问题。

and check which file is causing the problem in debugger.

这篇关于Django的:执行命令collectstatic统一筹集codeDE codeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆