Heroku开放不起作用。 " ValueError:文件' css / style.css'无法找到"

时间:2016-10-25 19:05:55

标签: python django heroku

我在使用heroku部署时遇到问题。当我在浏览器中打开应用程序时,它会向我显示一条错误消息:

  

内部服务器错误服务器遇到意外的内部错误   服务器错误(由女服务员生成)

我该如何解决这个问题?下面是heroku日志错误消息。正如你最后看到的那样,它向我展示了heroku无法找到css.file。从未在当地环境中遇到过这个问题。

感谢您的时间。

(venv) Ryujis-MacBook-Pro:ryujihellowebapp ryujimorita$ heroku logs
2016-10-25T18:40:40.739865+00:00 app[web.1]:     hashed_name = self.stored_name(clean_name)
2016-10-25T18:40:40.739866+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 280, in stored_name
2016-10-25T18:40:40.739868+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 94, in hashed_name
2016-10-25T18:40:40.739868+00:00 app[web.1]:     (clean_name, self))
2016-10-25T18:40:40.739867+00:00 app[web.1]:     cache_name = self.clean_name(self.hashed_name(name))
2016-10-25T18:40:40.739870+00:00 app[web.1]: ValueError: The file 'css/style.css' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7ff8f01577d0>.
2016-10-25T18:49:16.277858+00:00 heroku[router]: at=info method=GET path="/" host=ryujihellowebapp.herokuapp.com request_id=b7fa0f0e-33f5-4a20-a13d-272441b50c37 fwd="173.55.124.51" dyno=web.1 connect=1ms service=91ms status=500 bytes=269
2016-10-25T18:49:16.280970+00:00 app[web.1]: ERROR:django.request:Internal Server Error: /
2016-10-25T18:49:16.280980+00:00 app[web.1]: Traceback (most recent call last):
2016-10-25T18:49:16.280982+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
2016-10-25T18:49:16.280986+00:00 app[web.1]:     response = self.process_exception_by_middleware(e, request)
2016-10-25T18:49:16.280987+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
2016-10-25T18:49:16.280989+00:00 app[web.1]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
2016-10-25T18:49:16.280989+00:00 app[web.1]:   File "/app/collection/views.py", line 18, in index
2016-10-25T18:49:16.280991+00:00 app[web.1]:     'things': things,
2016-10-25T18:49:16.280992+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/shortcuts.py", line 67, in render
2016-10-25T18:49:16.280993+00:00 app[web.1]:     template_name, context, request=request, using=using)
2016-10-25T18:49:16.280994+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader.py", line 97, in render_to_string
2016-10-25T18:49:16.280995+00:00 app[web.1]:     return template.render(context, request)
2016-10-25T18:49:16.280995+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/backends/django.py", line 95, in render
2016-10-25T18:49:16.280996+00:00 app[web.1]:     return self.template.render(context)
2016-10-25T18:49:16.280997+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 206, in render
2016-10-25T18:49:16.280998+00:00 app[web.1]:     return self._render(context)
2016-10-25T18:49:16.280999+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 197, in _render
2016-10-25T18:49:16.280999+00:00 app[web.1]:     return self.nodelist.render(context)
2016-10-25T18:49:16.281000+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 992, in render
2016-10-25T18:49:16.281002+00:00 app[web.1]:     return self.render(context)
2016-10-25T18:49:16.281003+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader_tags.py", line 173, in render
2016-10-25T18:49:16.281004+00:00 app[web.1]:     return compiled_parent._render(context)
2016-10-25T18:49:16.281001+00:00 app[web.1]:     bit = node.render_annotated(context)
2016-10-25T18:49:16.281002+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 959, in render_annotated
2016-10-25T18:49:16.281004+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 197, in _render
2016-10-25T18:49:16.281005+00:00 app[web.1]:     return self.nodelist.render(context)
2016-10-25T18:49:16.281006+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 992, in render
2016-10-25T18:49:16.281007+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 959, in render_annotated
2016-10-25T18:49:16.281006+00:00 app[web.1]:     bit = node.render_annotated(context)
2016-10-25T18:49:16.281008+00:00 app[web.1]:     return self.render(context)
2016-10-25T18:49:16.281008+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/templatetags/static.py", line 103, in render
2016-10-25T18:49:16.281009+00:00 app[web.1]:     url = self.url(context)
2016-10-25T18:49:16.281010+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 16, in url
2016-10-25T18:49:16.281011+00:00 app[web.1]:     return static(path)
2016-10-25T18:49:16.281012+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 9, in static
2016-10-25T18:49:16.281013+00:00 app[web.1]:     return staticfiles_storage.url(path)
2016-10-25T18:49:16.281014+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 131, in url
2016-10-25T18:49:16.281014+00:00 app[web.1]:     hashed_name = self.stored_name(clean_name)
2016-10-25T18:49:16.281016+00:00 app[web.1]:     cache_name = self.clean_name(self.hashed_name(name))
2016-10-25T18:49:16.281016+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 94, in hashed_name
2016-10-25T18:49:16.281015+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 280, in stored_name
2016-10-25T18:49:16.281017+00:00 app[web.1]:     (clean_name, self))
2016-10-25T18:49:16.281019+00:00 app[web.1]: ValueError: The file 'css/style.css' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7ff8f01577d0>.
2016-10-25T18:49:16.283158+00:00 app[web.1]: ERROR:waitress:Exception when serving /
2016-10-25T18:49:16.283160+00:00 app[web.1]: Traceback (most recent call last):
2016-10-25T18:49:16.283161+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/waitress/channel.py", line 338, in service
2016-10-25T18:49:16.283162+00:00 app[web.1]:     task.service()
2016-10-25T18:49:16.283165+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/waitress/task.py", line 169, in service
2016-10-25T18:49:16.283165+00:00 app[web.1]:     self.execute()
2016-10-25T18:49:16.283166+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/waitress/task.py", line 399, in execute
2016-10-25T18:49:16.283167+00:00 app[web.1]:     app_iter = self.channel.server.application(env, start_response)
2016-10-25T18:49:16.283168+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/base.py", line 66, in __call__
2016-10-25T18:49:16.283168+00:00 app[web.1]:     return self.application(environ, start_response)
2016-10-25T18:49:16.283169+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 177, in __call__
2016-10-25T18:49:16.283170+00:00 app[web.1]:     response = self.get_response(request)
2016-10-25T18:49:16.283171+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 230, in get_response
2016-10-25T18:49:16.283172+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 296, in handle_uncaught_exception
2016-10-25T18:49:16.283171+00:00 app[web.1]:     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2016-10-25T18:49:16.283173+00:00 app[web.1]:     return callback(request, **param_dict)
2016-10-25T18:49:16.283173+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
2016-10-25T18:49:16.283174+00:00 app[web.1]:     response = view_func(request, *args, **kwargs)
2016-10-25T18:49:16.283174+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/views/defaults.py", line 63, in server_error
2016-10-25T18:49:16.283175+00:00 app[web.1]:     return http.HttpResponseServerError(template.render())
2016-10-25T18:49:16.283176+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/backends/django.py", line 95, in render
2016-10-25T18:49:16.283176+00:00 app[web.1]:     return self.template.render(context)
2016-10-25T18:49:16.283177+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 206, in render
2016-10-25T18:49:16.283178+00:00 app[web.1]:     return self._render(context)
2016-10-25T18:49:16.283179+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 197, in _render
2016-10-25T18:49:16.283180+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 992, in render
2016-10-25T18:49:16.283181+00:00 app[web.1]:     bit = node.render_annotated(context)
2016-10-25T18:49:16.283181+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 959, in render_annotated
2016-10-25T18:49:16.283179+00:00 app[web.1]:     return self.nodelist.render(context)
2016-10-25T18:49:16.283182+00:00 app[web.1]:     return self.render(context)
2016-10-25T18:49:16.283183+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader_tags.py", line 173, in render
2016-10-25T18:49:16.283184+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 197, in _render
2016-10-25T18:49:16.283185+00:00 app[web.1]:     return self.nodelist.render(context)
2016-10-25T18:49:16.283185+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 992, in render
2016-10-25T18:49:16.283186+00:00 app[web.1]:     bit = node.render_annotated(context)
2016-10-25T18:49:16.283183+00:00 app[web.1]:     return compiled_parent._render(context)
2016-10-25T18:49:16.283187+00:00 app[web.1]:     return self.render(context)
2016-10-25T18:49:16.283188+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/templatetags/static.py", line 103, in render
2016-10-25T18:49:16.283189+00:00 app[web.1]:     url = self.url(context)
2016-10-25T18:49:16.283190+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 16, in url
2016-10-25T18:49:16.283190+00:00 app[web.1]:     return static(path)
2016-10-25T18:49:16.283191+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 9, in static
2016-10-25T18:49:16.283192+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 131, in url
2016-10-25T18:49:16.283187+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 959, in render_annotated
2016-10-25T18:49:16.283194+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 280, in stored_name
2016-10-25T18:49:16.283193+00:00 app[web.1]:     hashed_name = self.stored_name(clean_name)
2016-10-25T18:49:16.283194+00:00 app[web.1]:     cache_name = self.clean_name(self.hashed_name(name))
2016-10-25T18:49:16.283195+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 94, in hashed_name
2016-10-25T18:49:16.283196+00:00 app[web.1]:     (clean_name, self))
2016-10-25T18:49:16.283197+00:00 app[web.1]: ValueError: The file 'css/style.css' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7ff8f01577d0>.
2016-10-25T18:49:16.283192+00:00 app[web.1]:     return staticfiles_storage.url(path)

这是我的静态设置:

STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

STATIC_URL = '/static/' STATIC_ROOT = 'staticfiles' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )

这是我的模板,base-html:

0 个答案:

没有答案