简体   繁体   English

提供JS文件时,Django dj-static错误

[英]Django dj-static error when serving JS files

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

I'm getting this. 我明白了 Any ideas? 有任何想法吗? Only happens with JavaScript files. 仅在JavaScript文件中发生。 Versions: dj-static==0.0.5, static==1.0.2, and django-pipeline==1.3.16, Django=1.6.1. 版本:dj-static == 0.0.5,static == 1.0.2和django-pipeline == 1.3.16,Django = 1.6.1。

Not much of an answer, I know, but taking out dj-static did it for me. 我知道答案不多,但是取出dj-static对我有用。 You really don't need it if your using pipeline anyway as pipeline takes care of compiling your static files and putting them in a place where they can be served so long as you include the line: 如果您仍然使用管道作为管道,因为您会使用它来编译静态文件并将它们放置在可以提供它们的位置,只要您包含以下行,您就真的不需要它:

(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}) in your urls.py (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT})在您的urls.py中

Issue was older versions of django-pipeline messaged with mimetypes entering unicode strings (not byte strings). 问题是django-pipeline较旧版本发出的消息是, mimetypes输入了unicode字符串(而不是字节字符串)。 Updating to version 1.3.22 fixes this. 更新到版本1.3.22可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM