我在将django应用程序部署到heroku时遇到问题
当从heroku运行时,它会抛出一个警告说没有找到css文件,但是当我在我的localhost上运行它时,具有相同路径的css文件工作,为什么会这样呢?我该如何解决?2012-03-09T02:38:13+00:00 heroku[web.1]: Starting process with command `python platformsite/manage.py runserver 0.0.0.0:32499 --noreload`
2012-03-09T02:38:14+00:00 heroku[web.1]: Error R12 (Exit timeout) -> Process failed to exit within 10 seconds of SIGTERM
2012-03-09T02:38:14+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-03-09T02:38:16+00:00 heroku[web.1]: Process exited with status 137
2012-03-09T02:38:17+00:00 app[web.1]: Validating models...
2012-03-09T02:38:17+00:00 app[web.1]:
2012-03-09T02:38:18+00:00 app[web.1]: 0 errors found
2012-03-09T02:38:18+00:00 app[web.1]: Django version 1.4c1, using settings 'platformsite.settings'
2012-03-09T02:38:18+00:00 app[web.1]: Quit the server with CONTROL-C.
2012-03-09T02:38:18+00:00 app[web.1]: Development server is running at http://0.0.0.0:32499/
2012-03-09T02:38:18+00:00 heroku[web.1]: State changed from starting to up
2012-03-09T02:38:21+00:00 app[web.1]: [09/Mar/2012 02:38:21] "GET /accounts/home/ HTTP/1.1" 200 10810
2012-03-09T02:38:21+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/accounts/home/ dyno=web.1 queue=0 wait=0ms service=780ms status=200 bytes=10810
2012-03-09T02:38:22+00:00 app[web.1]: WARNING 2012-03-09 02:38:22,487 base 1 140501516363520 Not Found: /common/static/common/third_party/blueprint/plugins/link-icons/screen.css
2012-03-09T02:38:22+00:00 app[web.1]: WARNING 2012-03-09 02:38:22,554 base 1 140501486782208 Not Found: /common/static/common/third_party/uni-form/css/uni-form.css
2012-03-09T02:38:22+00:00 app[web.1]: WARNING 2012-03-09 02:38:22,567 base 1 140501476292352 Not Found: /common/static/common/third_party/blueprint/screen.css
2012-03-09T02:38:22+00:00 app[web.1]: WARNING 2012-03-09 02:38:22,582 base 1 140501497272064 Not Found: /common/static/common/third_party/uni-form/css/blue.uni-form.css
2012-03-09T02:38:22+00:00 app[web.1]: WARNING 2012-03-09 02:38:22,625 base 1 140501465802496 Not Found: /common/static/common/third_party/jquery-ui/custom-theme/jquery-ui.custom.css
2012-03-09T02:38:22+00:00 app[web.1]: [09/Mar/2012 02:38:22] "GET /common/static/common/third_party/blueprint/plugins/link-icons/screen.css HTTP/1.1" 404 5607
2012-03-09T02:38:22+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/third_party/blueprint/plugins/link-icons/screen.css dyno=web.1 queue=0 wait=0ms service=475ms status=404 bytes=5607
2012-03-09T02:38:22+00:00 app[web.1]: [09/Mar/2012 02:38:22] "GET /common/static/common/third_party/blueprint/screen.css HTTP/1.1" 404 5607
2012-03-09T02:38:22+00:00 app[web.1]: [09/Mar/2012 02:38:22] "GET /common/static/comm
2012-03-09T02:38:22+00:00 app[web.1]: [09/Mar/2012 02:38:22] "GET /common/static/common/third_party/jquery-ui/custom-theme/jquery-ui.custom.css HTTP/1.1" 404 5607
2012-03-09T02:38:22+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/third_party/blueprint/screen.css dyno=web.1 queue=0 wait=0ms service=476ms status=404 bytes=5607
2012-03-09T02:38:22+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/third_party/jquery-ui/custom-theme/jquery-ui.custom.css dyno=web.1 queue=0 wait=0ms service=478ms status=404 bytes=5607
2012-03-09T02:38:22+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/third_party/uni-form/css/uni-form.css dyno=web.1 queue=0 wait=0ms service=478ms status=404 bytes=5607
2012-03-09T02:38:22+00:00 app[web.1]: [09/Mar/2012 02:38:22] "GET /common/static/common/third_party/uni-form/css/blue.uni-form.css HTTP/1.1" 404 5607
2012-03-09T02:38:22+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/third_party/uni-form/css/blue.uni-form.css dyno=web.1 queue=0 wait=0ms service=490ms status=404 bytes=5607
2012-03-09T02:38:22+00:00 app[web.1]: WARNING 2012-03-09 02:38:22,802 base 1 140501455312640 Not Found: /common/static/common/css/common.css
2012-03-09T02:38:22+00:00 app[web.1]: [09/Mar/2012 02:38:22] "GET /common/static/common/css/common.css HTTP/1.1" 404 5607
2012-03-09T02:38:22+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/css/common.css dyno=web.1 queue=0 wait=0ms service=381ms status=404 bytes=5607
2012-03-09T02:38:23+00:00 app[web.1]: WARNING 2012-03-09 02:38:23,354 base 1 140501455312640 Not Found: /common/static/accounts/css/accounts.css
2012-03-09T02:38:23+00:00 app[web.1]: WARNING 2012-03-09 02:38:23,437 base 1 140501465802496 Not Found: /common/static/common/third_party/jquery.tools.min.js
2012-03-09T02:38:23+00:00 app[web.1]: WARNING 2012-03-09 02:38:23,486 base 1 140501497272064 Not Found: /common/static/common/third_party/jquery.js
2012-03-09T02:38:23+00:00 app[web.1]: [09/Mar/2012 02:38:23] "GET /common/static/accounts/css/accounts.css HTTP/1.1" 404 5607
2012-03-09T02:38:23+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/accounts/css/accounts.css dyno=web.1 queue=0 wait=0ms service=348ms status=404 bytes=5607
2012-03-09T02:38:23+00:00 app[web.1]: [09/Mar/2012 02:38:23] "GET /common/static/common/third_party/jquery.tools.min.js HTTP/1.1" 404 5607
2012-03-09T02:38:23+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/third_party/jquery.tools.min.js dyno=web.1 queue=0 wait=0ms service=355ms status=404 bytes=5607
2012-03-09T02:38:23+00:00 app[web.1]: [09/Mar/2012 02:38:23] "GET /common/static/common/third_party/jquery.js HTTP/1.1" 404 5607
2012-03-09T02:38:23+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/third_party/jquery.js dyno=web.1 queue=0 wait=0ms service=374ms status=404 bytes=5607
2012-03-09T02:38:23+00:00 app[web.1]: WARNING 2012-03-09 02:38:23,582 base 1 140501476292352 Not Found: /common/static/common/js/django_jquery_ajax.js
2012-03-09T02:38:23+00:00 app[web.1]: [09/Mar/2012 02:38:23] "GET /common/static/common/js/django_jquery_ajax.js HTTP/1.1" 404 5607
2012-03-09T02:38:23+00:00 heroku[router]: GET pure-fire-3271.herokuapp.com/common/static/common/js/django_jquery_ajax.js dyno=web.1 queue=0 wait=0ms service=232ms status=404 bytes=5607
2012-03-09T02:38:23+00:00 app[web.1]: WARNING 2012-03-09 02:38:23,688 base 1 140501516363520 Not Found: /common/static/common/third_party/jquery-ui/jquery-ui.min.js
2012-03-09T02:38:23+00:00 app[web.1]: WARNING 2012-03-09 02:38:23,838 base 1 140501486782208 Not Found: /common/static/common/js/utils.js
2012-03-09T02:38:23+00:00 app[web.1]: [09/Mar/2012 02:38:23] "GET /common/static/common/third_party/jquery-ui/jquery-ui.min.js HTTP/1.1" 404 5607
2012-03-09T02:38:23+00:00 app[web.1]: [09/Mar/2012 02:38:23] "GET /common/static/common/js/utils.js HTTP/1.1" 404 5607
这是localhost上的日志
[09/Mar/2012 03:29:43] "GET /accounts/home/ HTTP/1.1" 200 10698
[09/Mar/2012 03:29:43] "GET /static/common/third_party/jquery-ui/custom-theme/jquery-ui.custom.css HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/third_party/blueprint/plugins/link-icons/screen.css HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/third_party/uni-form/css/uni-form.css HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/third_party/blueprint/screen.css HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/third_party/uni-form/css/blue.uni-form.css HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/third_party/jquery.js HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/css/common.css HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/third_party/jquery.tools.min.js HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/third_party/jquery-ui/jquery-ui.min.js HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/js/utils.js HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/accounts/css/accounts.css HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/js/django_jquery_ajax.js HTTP/1.1" 304 0
[09/Mar/2012 03:29:43] "GET /static/common/js/getUrlParam.js HTTP/1.1" 304 0
[09/Mar/2012 03:29:44] "GET /static/common/third_party/uni-form/js/uni-form-validation.jquery.js HTTP/1.1" 304 0
[09/Mar/2012 03:29:44] "GET /static/common/images/masthead_logo.png HTTP/1.1" 304 0
[09/Mar/2012 03:29:44] "GET /static/accounts/images/social_net.png HTTP/1.1" 304 0
[09/Mar/2012 03:29:44] "GET /static/common/third_party/blueprint/plugins/link-icons/icons/email.png HTTP/1.1" 304 0
[09/Mar/2012 03:29:44] "GET /static/common/third_party/blueprint/print.css HTTP/1.1" 304 0
WARNING 2012-03-09 03:29:44,792 base 32613 4349497344 Not Found: /favicon.ico
答案 0 :(得分:2)
已添加到myapp / urls.py
if not settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
)
和
添加到Procfile
web: python myapp/manage.py collectstatic --noinput; bin/gunicorn_django --workers=4 --bind=0.0.0.0:$PORT myapp/settings.py