Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django Heroku服务器错误(500),当我将Debug-False设置为True时,它工作正常_Django_Heroku - Fatal编程技术网

Django Heroku服务器错误(500),当我将Debug-False设置为True时,它工作正常

Django Heroku服务器错误(500),当我将Debug-False设置为True时,它工作正常,django,heroku,Django,Heroku,我知道这方面有很多问题,但老实说,大多数问题都没有答案,或者解决方案不起作用 我有个“简单”的问题。当我将Debug设置为False并将其推送到heroku时,我会得到“Server Error(500)”。我读了这些主题: 我尝试了他们的解决方案,但仍然不起作用。唯一的解决方案,我没有测试,应该是帮助摆脱白噪声。这个对我来说有点“不行” 对此错误我能做些什么 谢谢,干杯 编辑: 这是我的日志。我试着把白噪音注释掉,但没用 我在查看我的代码,但我没有提到“favicon.ico”。另外,

我知道这方面有很多问题,但老实说,大多数问题都没有答案,或者解决方案不起作用

我有个“简单”的问题。当我将Debug设置为False并将其推送到heroku时,我会得到“Server Error(500)”。我读了这些主题:

我尝试了他们的解决方案,但仍然不起作用。唯一的解决方案,我没有测试,应该是帮助摆脱白噪声。这个对我来说有点“不行”

对此错误我能做些什么

谢谢,干杯

编辑:

这是我的日志。我试着把白噪音注释掉,但没用

我在查看我的代码,但我没有提到“favicon.ico”。另外,我尝试运行collectstatic,因为我发现了一些与此相关的主题,但它对我不起作用

首先它问我:

You have requested to collect static files at the destination
location as specified in your settings:

    /app/staticfiles
然后我得到了一个错误:

FileNotFoundError: [Errno 2] No such file or directory: '/app/static'
这很奇怪,因为首先它向我证实了我将这个文件夹从静态文件过度引用到了静态文件。在我的主目录中有一个文件夹“staticfiles”。在我的应用程序文件夹中,我有“静态”文件夹。关闭调试后,一切正常

    2020-05-19T05:15:40.192943+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=robotbuilder.herokuapp.com request_id=eeaf4fd1-b73b-4e84-aacd-7e701d3e8932 fwd="83.26.255.146" dyno=web.1 connect=1ms service=3ms status=404 bytes=388 protocol=http

2020-05-19T05:15:39.991705+00:00 app[web.1]: [2020-05-19 05:15:39 +0000] [11] [ERROR] Error handling request /

2020-05-19T05:15:39.991725+00:00 app[web.1]: Traceback (most recent call last):

2020-05-19T05:15:39.991726+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle

2020-05-19T05:15:39.991734+00:00 app[web.1]:     self.handle_request(listener, req, client, addr)

2020-05-19T05:15:39.991734+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 175, in handle_request

2020-05-19T05:15:39.991735+00:00 app[web.1]:     respiter = self.wsgi(environ, resp.start_response)

2020-05-19T05:15:39.991735+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 133, in __call__

2020-05-19T05:15:39.991735+00:00 app[web.1]:     response = self.get_response(request)

2020-05-19T05:15:39.991736+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 75, in get_response

2020-05-19T05:15:39.991736+00:00 app[web.1]:     response = self._middleware_chain(request)

2020-05-19T05:15:39.991736+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991737+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991739+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991740+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991741+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991741+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991741+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/whitenoise/middleware.py", line 58, in __call__

2020-05-19T05:15:39.991742+00:00 app[web.1]:     response = self.get_response(request)

2020-05-19T05:15:39.991746+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991747+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991747+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991747+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991747+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991748+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991748+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__

2020-05-19T05:15:39.991748+00:00 app[web.1]:     response = response or self.get_response(request)

2020-05-19T05:15:39.991748+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991749+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991749+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991749+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991750+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991750+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991750+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__

2020-05-19T05:15:39.991750+00:00 app[web.1]:     response = response or self.get_response(request)

2020-05-19T05:15:39.991751+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991751+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991751+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991752+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991752+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991752+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991752+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__

2020-05-19T05:15:39.991753+00:00 app[web.1]:     response = response or self.get_response(request)

2020-05-19T05:15:39.991753+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991753+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991753+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991754+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991754+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991755+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991763+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__

2020-05-19T05:15:39.991763+00:00 app[web.1]:     response = response or self.get_response(request)

2020-05-19T05:15:39.991763+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991764+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991764+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991764+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991764+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991765+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991765+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__

2020-05-19T05:15:39.991765+00:00 app[web.1]:     response = response or self.get_response(request)

2020-05-19T05:15:39.991765+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991766+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991766+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991766+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991766+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991767+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991767+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__

2020-05-19T05:15:39.991767+00:00 app[web.1]:     response = response or self.get_response(request)

2020-05-19T05:15:39.991767+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991768+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991768+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991768+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991768+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991769+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991769+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__

2020-05-19T05:15:39.991769+00:00 app[web.1]:     response = response or self.get_response(request)

2020-05-19T05:15:39.991769+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991770+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991770+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991770+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991771+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991771+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991771+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/whitenoise/middleware.py", line 58, in __call__

2020-05-19T05:15:39.991771+00:00 app[web.1]:     response = self.get_response(request)

2020-05-19T05:15:39.991772+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

2020-05-19T05:15:39.991772+00:00 app[web.1]:     response = response_for_exception(request, exc)

2020-05-19T05:15:39.991772+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

2020-05-19T05:15:39.991772+00:00 app[web.1]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

2020-05-19T05:15:39.991780+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

2020-05-19T05:15:39.991781+00:00 app[web.1]:     response = get_response(request)

2020-05-19T05:15:39.991781+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response

2020-05-19T05:15:39.991782+00:00 app[web.1]:     response = self.process_exception_by_middleware(e, request)

2020-05-19T05:15:39.991782+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response

2020-05-19T05:15:39.991782+00:00 app[web.1]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)

2020-05-19T05:15:39.991783+00:00 app[web.1]:   File "/app/builder/views.py", line 8, in home

2020-05-19T05:15:39.991783+00:00 app[web.1]:     return render(request, "builder/home.html")

2020-05-19T05:15:39.991783+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/shortcuts.py", line 19, in render

2020-05-19T05:15:39.991784+00:00 app[web.1]:     content = loader.render_to_string(template_name, context, request, using=using)

2020-05-19T05:15:39.991790+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader.py", line 62, in render_to_string

2020-05-19T05:15:39.991790+00:00 app[web.1]:     return template.render(context, request)

2020-05-19T05:15:39.991791+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render

2020-05-19T05:15:39.991791+00:00 app[web.1]:     return self.template.render(context)

2020-05-19T05:15:39.991791+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 171, in render

2020-05-19T05:15:39.991792+00:00 app[web.1]:     return self._render(context)

2020-05-19T05:15:39.991792+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 163, in _render

2020-05-19T05:15:39.991792+00:00 app[web.1]:     return self.nodelist.render(context)

2020-05-19T05:15:39.991792+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 936, in render

2020-05-19T05:15:39.991793+00:00 app[web.1]:     bit = node.render_annotated(context)

2020-05-19T05:15:39.991793+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 903, in render_annotated

2020-05-19T05:15:39.991798+00:00 app[web.1]:     return self.render(context)

2020-05-19T05:15:39.991798+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render

2020-05-19T05:15:39.991798+00:00 app[web.1]:     return compiled_parent._render(context)

2020-05-19T05:15:39.991799+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 163, in _render

2020-05-19T05:15:39.991799+00:00 app[web.1]:     return self.nodelist.render(context)

2020-05-19T05:15:39.991799+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 936, in render

2020-05-19T05:15:39.991799+00:00 app[web.1]:     bit = node.render_annotated(context)

2020-05-19T05:15:39.991800+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 903, in render_annotated

2020-05-19T05:15:39.991800+00:00 app[web.1]:     return self.render(context)

2020-05-19T05:15:39.991800+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 106, in render

2020-05-19T05:15:39.991800+00:00 app[web.1]:     url = self.url(context)

2020-05-19T05:15:39.991804+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 103, in url

2020-05-19T05:15:39.991804+00:00 app[web.1]:     return self.handle_simple(path)

2020-05-19T05:15:39.991804+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 118, in handle_simple

2020-05-19T05:15:39.991805+00:00 app[web.1]:     return staticfiles_storage.url(path)

2020-05-19T05:15:39.991805+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 153, in url

2020-05-19T05:15:39.991805+00:00 app[web.1]:     return self._url(self.stored_name, name, force)

2020-05-19T05:15:39.991806+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 132, in _url

2020-05-19T05:15:39.991806+00:00 app[web.1]:     hashed_name = hashed_name_func(*args)

2020-05-19T05:15:39.991806+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 423, in stored_name

2020-05-19T05:15:39.991806+00:00 app[web.1]:     raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)

2020-05-19T05:15:39.991807+00:00 app[web.1]: ValueError: Missing staticfiles manifest entry for 'builder/logo.png'

2020-05-19T05:15:39.992027+00:00 app[web.1]: 10.95.191.28 - - [19/May/2020:05:15:39 +0000] "GET / HTTP/1.1" 500 0 "-" "-"

2020-05-19T05:15:40.192825+00:00 app[web.1]: 10.95.191.28 - - [19/May/2020:05:15:40 +0000] "GET /favicon.ico HTTP/1.1" 404 179 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0"

2020-05-19T05:15:39.996509+00:00 heroku[router]: at=info method=GET path="/" host=robotbuilder.herokuapp.com request_id=de877e93-558a-40ab-bf11-b6de261cb707 fwd="83.26.255.146" dyno=web.1 connect=1ms service=57ms status=500 bytes=244 protocol=http
编辑2:

    import os
import django_heroku
from decouple import config
import dj_database_url

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'builder',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    # Simplified static file serving.
    # https://warehouse.python.org/project/whitenoise/
    'whitenoise.middleware.WhiteNoiseMiddleware',
]

ROOT_URLCONF = 'robot_builder.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'robot_builder.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
    }
}
# If you want to work with your remote database on your local machine, you need to paste link from heroku lower:
# DATABASES['default'] = dj_database_url.config(default='postgres://qkwlkrkahynyik:21a1420ab5820795f3a0c736ebb607419fc7a111f093924dcfc4567dfd906b9f@ec2-54-147-209-121.compute-1.amazonaws.com:5432/d2v01dp40p4er2')

db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)

# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

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


# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'


 # Debugging in heroku live
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': ('%(asctime)s [%(process)d] [%(levelname)s] ' +
                       'pathname=%(pathname)s lineno=%(lineno)s ' +
                       'funcname=%(funcName)s %(message)s'),
            'datefmt': '%Y-%m-%d %H:%M:%S'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        }
    },
    'handlers': {
        'null': {
            'level': 'DEBUG',
            'class': 'logging.NullHandler',
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'testlogger': {
            'handlers': ['console'],
            'level': 'INFO',
        }
    }
}

DEBUG_PROPAGATE_EXCEPTIONS = True
COMPRESS_ENABLED = os.environ.get('COMPRESS_ENABLED', False)


# Activate Django-Heroku.
django_heroku.settings(locals())
我的文件夹结构:

robot_builder
    > builder
        >> migrations
        >> static
            >>> css
            >>> builder
                >>>> my images, including logo.png used as favicon
        >> templates
        >> models.py etc.
    > media
    > robot_builder
        >> settings.py etc.
    > staticfiles

通过日志调试django应用程序,方法是键入以下内容,
heroku logs--tail-a您的_herokuapp_name

在此之前,请将其添加到
设置.py中:

 # Debugging in heroku live
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': ('%(asctime)s [%(process)d] [%(levelname)s] ' +
                       'pathname=%(pathname)s lineno=%(lineno)s ' +
                       'funcname=%(funcName)s %(message)s'),
            'datefmt': '%Y-%m-%d %H:%M:%S'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        }
    },
    'handlers': {
        'null': {
            'level': 'DEBUG',
            'class': 'logging.NullHandler',
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'testlogger': {
            'handlers': ['console'],
            'level': 'INFO',
        }
    }
}

DEBUG_PROPAGATE_EXCEPTIONS = True
COMPRESS_ENABLED = os.environ.get('COMPRESS_ENABLED', False)
这将显示heroku日志中的
debug=False
错误


通过日志调试django应用程序,方法是键入以下内容,
heroku logs--tail-a您的\u herokuapp\u名称

在此之前,请将其添加到
设置.py中:

 # Debugging in heroku live
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': ('%(asctime)s [%(process)d] [%(levelname)s] ' +
                       'pathname=%(pathname)s lineno=%(lineno)s ' +
                       'funcname=%(funcName)s %(message)s'),
            'datefmt': '%Y-%m-%d %H:%M:%S'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        }
    },
    'handlers': {
        'null': {
            'level': 'DEBUG',
            'class': 'logging.NullHandler',
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'testlogger': {
            'handlers': ['console'],
            'level': 'INFO',
        }
    }
}

DEBUG_PROPAGATE_EXCEPTIONS = True
COMPRESS_ENABLED = os.environ.get('COMPRESS_ENABLED', False)
这将显示heroku日志中的
debug=False
错误


我想我明白了。解决方案正在发挥作用。但我觉得这也很奇怪。如果有人能评论一下为什么会这样,我将不胜感激

您可以离开whitenoise,您可以稍微整理一下静态文件dirs。让它看起来像这样:

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
但我认为这没有必要。(最好将“静态”文件夹保存在主项目文件夹中)

但最大的问题是(在django 3上工作):

你需要跑步

python manage.py collectstatic
本地的!然后交给希罗库。然后,调试设置为False时,一切正常。我试着保持静态。保持文件。我尝试只提交.json,希望它能重新填充新的静态文件。但不行。只有在本地运行collectstatic,然后将所有内容提交给heroku时,它才起作用

如果有人对这个问题有更多的了解,并能向我解释,我将非常感激

同时,我希望其他人也能从这个解决方案中受益


我找到了这个问题的答案-。非常感谢emazzotta,我也不必摆脱whitenoise,它在django3工作。

我想我已经搞定了。解决方案正在发挥作用。但我觉得这也很奇怪。如果有人能评论一下为什么会这样,我将不胜感激

您可以离开whitenoise,您可以稍微整理一下静态文件dirs。让它看起来像这样:

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
但我认为这没有必要。(最好将“静态”文件夹保存在主项目文件夹中)

但最大的问题是(在django 3上工作):

你需要跑步

python manage.py collectstatic
本地的!然后交给希罗库。然后,调试设置为False时,一切正常。我试着保持静态。保持文件。我尝试只提交.json,希望它能重新填充新的静态文件。但不行。只有在本地运行collectstatic,然后将所有内容提交给heroku时,它才起作用

如果有人对这个问题有更多的了解,并能向我解释,我将非常感激

同时,我希望其他人也能从这个解决方案中受益


我找到了这个问题的答案-。非常感谢emazzotta,我还没有摆脱whitenoise,它在django3中工作。

ValueError:缺少'builder/logo.png'的staticfiles清单条目。

似乎在
builder/staticfiles(/builder)
中,引用了
logo.png
,但并不存在。这可能是因为它试图访问
静态文件
,而不是
静态文件
,在这种情况下,这似乎是一个内部错误,将在Django的更高版本中修复。鉴于您正在使用Django 2,如果添加
logo.png
不起作用,您可能应该升级到Django 3


TL;DR:将
logo.png
添加到
builder/staticfiles(/builder)
或升级Django。

value错误:缺少“builder/logo.png”的staticfiles清单条目。

似乎在
builder/staticfiles(/builder)
中,引用了
logo.png
,但并不存在。这可能是因为它试图访问
静态文件
,而不是
静态文件
,在这种情况下,这似乎是一个内部错误,将在Django的更高版本中修复。鉴于您正在使用Django 2,如果添加
logo.png
不起作用,您可能应该升级到Django 3


TL;DR:将
logo.png
添加到
builder/staticfiles(/builder)
或升级Django。

在不使用whitenoise的情况下尝试一次,看看是否会导致问题。我尝试注释掉whitenoise,但没有帮助,我在编辑的帖子中添加了我的日志。请编辑你的帖子,使其包含静态设置。还请显示你的目录结构以及什么是
static\u TMP=os.path.join(BASE\u DIR,'static')
?如果您的
staticfiles/
文件夹不包含任何内容,您可以将其删除,并将您的
static/
文件夹提升到与根目录中的
staticfiles/
相同的级别。然后测试它是否有效。在没有whitenoise的情况下尝试一次,看看它是否会导致问题。我试图对whiten进行注释