【发布时间】:2015-06-20 06:07:02
【问题描述】:
这是我的文件夹结构
Music
-Music
-Feature
-static
-feature
core.css
-css
other css files
-js
-img
-templates
404.html
500.html
index.html
-feature
about.html
detail.html
template.html
manage.py
views.py
from django.shortcuts import render
def error404(request):
return render(request,'404.html')
urls.py
urlpatterns = [
url(r'^featured/(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'),
url(r'^about/$', views.about, name='about'),
url(r'^FAQ/$', views.faq, name='faq'),
]
handler404 = 'mysite.views.error404'
自定义 404.html 文件被渲染但没有 css。通常 css 在其他页面上工作正常但是当我设置debug=false以检查 settings.py 中的自定义 404 错误页面时,整个项目的 css 消失了.与文件夹结构或其他问题有关吗?
编辑:core.css 是主要的 css 文件,带有 other css files 的部分包含用于插件的 css
【问题讨论】:
-
你的 handler404 和视图没问题。但你不需要它们。只需一个自定义 404 模板就足够了。