版本:
System version : Windows 10,Ubuntu16.04
Python version : Python 3.6.0 :: Anaconda 4.3.1 (64-bit)
Django version : 1.11.2
檔案結構:
◢ project_name
◢ app_name
◢ templates
◢ app_name
page1.html
404.html
urls.py
views.py
◢ project_name
settings.py
urls.py
views.py
◢ static
◢ css
◢ js
◢ image
favicon.png
manage.py
project_name/project_name/urls.py
加入以下程式碼
handler404 = views.error_404
handler500 = views.error_404
project_name/project_name/views.py
加入以下程式碼
from django.shortcuts import render
def error_404(request):
return render(request, 'app_name/404.html')
project_name/project_name/settings.py
將DEBUG的值改為False
# DEBUG = True
DEBUG = False
沒有留言:
張貼留言