簡體   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