服务JS文件时出现Django dj-static错误

时间:2014-02-08 03:49:23

标签: javascript python django django-staticfiles

2014-02-08T00:17:59.628381+00:00 app[web.1]: Traceback (most recent call last):
2014-02-08T00:17:59.628381+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/wsgiref/handlers.py", line 85, in run
2014-02-08T00:17:59.628381+00:00 app[web.1]:     self.result = application(self.environ, self.start_response)
2014-02-08T00:17:59.628381+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/dj_static.py", line 64, in __call__
2014-02-08T00:17:59.628381+00:00 app[web.1]:     return self.cling(environ, start_response)
2014-02-08T00:17:59.628381+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/static/apps.py", line 118, in __call__
2014-02-08T00:17:59.628381+00:00 app[web.1]:     start_response("200 OK", headers)
2014-02-08T00:17:59.628381+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/wsgiref/handlers.py", line 180, in start_response
2014-02-08T00:17:59.628381+00:00 app[web.1]:     assert type(val) is StringType,"Header values must be strings"
2014-02-08T00:17:59.628381+00:00 app[web.1]: AssertionError: Header values must be strings

我得到了这个。有任何想法吗?只有JavaScript文件才会发生。版本:dj-static == 0.0.5,static == 1.0.2,django-pipeline == 1.3.16,Django = 1.6.1。

2 个答案:

答案 0 :(得分:0)

我知道,答案不是很多,但取出dj-static为我做了。你真的不需要它,如果你使用管道作为管道负责编译静态文件并将它们放在可以提供它们的地方,只要你包括这一行:

你的urls.py中有

(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT})

答案 1 :(得分:0)

问题是django-pipeline的旧版本消息,其中mimetypes输入了unicode字符串(不是字节字符串)。更新到版本1.3.22修复了此问题。