1

manojmj.herokuapp.com に簡単なポートフォリオ Web サイトを作成しました。

画像や css などを heroku 自体でホストしたいのですが、サイズが 800kb しかないため、s3 に移動したくありません。

私のサイトは正常に動作しており、ローカル開発サーバー (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'),
4

1 に答える 1

1

この行を変更してみてください:

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'}),
于 2013-06-21T15:32:50.480 に答える