繁体   English   中英

从heroku提供静态文件

[英]serving static files from heroku

我在manojmj.herokuapp.com上创建了一个简单的投资组合网站

我想在heroku本身上托管图像,css等,并且不希望移动到s3,因为它只有800kb的大小。

我的网站运行良好,并且在本地开发服务器上正确显示了图像(127.0.0.1:8000)

但是,在manojmj.herokuapp.com上,我只能看到标记,而看不到图像。 单击图像URL时出现错误:

ValueError at /static/images/me.jpg
dictionary update sequence element #0 has length 35; 2 is required
Request Method: GET
Request URL:    http://www.manojmj.com/static/images/me.jpg
Django Version: 1.4.3
Exception Type: ValueError
Exception Value:    
dictionary update sequence element #0 has length 35; 2 is required
Exception Location: /app/.heroku/python/lib/python2.7/site-      packages/django/core/urlresolvers.py in resolve, line 207
Python Executable:  /app/.heroku/python/bin/python
Python Version: 2.7.4
Python Path:    
['/app',
 '/app/.heroku/python/bin',
 '/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg',
 '/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
 '/app',
 '/app/.heroku/python/lib/python27.zip',
 '/app/.heroku/python/lib/python2.7',
 '/app/.heroku/python/lib/python2.7/plat-linux2',
 '/app/.heroku/python/lib/python2.7/lib-tk',
 '/app/.heroku/python/lib/python2.7/lib-old',
 '/app/.heroku/python/lib/python2.7/lib-dynload',
 '/app/.heroku/python/lib/python2.7/site-packages',
 '/app/.heroku/python/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
 Server time:   Fri, 21 Jun 2013 09:37:01 -0500

我的urls.py

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

url(r'^$', 'manojmjapp.views.home'),

尝试更改此行:

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

为了这:

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

暂无
暂无

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

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