我在我的django应用程序中出现了一个自定义的error_page,当出现问题时我会调用它。问题是当我尝试加载我的' base.html'或者与javascript,CSS或python代码有关的任何内容我得到的错误如下:
ValueError: The file 'style.css' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7ff3b288d9d0>.
这是我的代码:
URLS.PY
from django.conf.urls import handler400, handler403, handler404, handler500
handler500 = main_views.server_error
MAIN_VIEWS.PY
def server_error(request):
return render (request, 'error_page.html', status=500)
ERROR_PAGE.HTML
{% extends "account/base.html" %}
{% block head_title %}Error Page{% endblock %}
{% block content %}
<script>
setTimeout(function() {
$.get("{% url 'home_page' %}") // Do something after 5 seconds
}, 5000);
<script/>
<h1><b>AN ERROR OCURRED! THIS PAGE DOESN'T EXISTS OR COULDN'T BE FIND! YOU WILL BE REDIRECTED TO HOME PAGE IN 5 SECONDS...</b></h1>
{% endblock content %}
出了什么问题?
答案 0 :(得分:0)
在使用python manage.py collectstatic
DEBUG=False
此外,在您的settins.py
中,您应该:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')