赞
踩
DEBUG = False
ALLOWED_HOSTS = ["*"]
STATIC_URL = '/static/'
STATIC_ROOT = 'static
2.设置主urls
from . import view
urlpatterns = [
path('admin/', admin.site.urls),
path('', view.index),
........
# 增加以下一行,以识别静态资源
url(r'^static/(?P<path>.*)$', static.serve,
{'document_root': settings.STATIC_ROOT}, name='static')
]
# 配置异常页面
handler403 = view.page_permission_denied
handler404 = view.page_not_found
handler500 = view.page_inter_error
from django.shortcuts import render
def page_not_found(request):
return render(request, '404.html')
def page_permission_denied(request):
return render(request, '403.html')
def page_inter_error(request):
return render(request, '500.html')
4.在templates中添加404.html,403.html,500.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。