完善404页面

This commit is contained in:
yangjian 2019-07-30 17:59:27 +08:00
parent a8b20f7882
commit f6829ba7f2
3 changed files with 11 additions and 5 deletions

View File

@ -23,7 +23,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '5&71mt9@^58zdg*_!t(x6g14q*@84d%ptr%%s6e0l50zs0we3d'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False
ALLOWED_HOSTS = ['*']
@ -122,11 +122,13 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR,'static'),]
if DEBUG:
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ]
else:
STATIC_ROOT = os.path.join(BASE_DIR,'static')
# 媒体文件
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
# 日志配置

View File

@ -22,5 +22,6 @@ urlpatterns = [
path('admin/', admin.site.urls),
path('',include('app_doc.urls')),
path('user/',include('app_admin.urls'),),
re_path('^static/(?P<path>.*)$',serve,{'document_root':settings.STATIC_ROOT}),# 静态文件
re_path('^media/(?P<path>.*)$',serve,{'document_root':settings.MEDIA_ROOT}),# 媒体文件
]

View File

@ -44,8 +44,11 @@
</div>
</div>
<div class="layui-main">
<div class="project-item">
<div style="text-align: center;margin-top: 20px;">
<h1>
<strong>页面未找到……</strong>
</h1>
<p><a href="{% url 'pro_list' %}" >返回首页</a></p>
</div>
</div>