#views.py文件 |
def page_not_found_view(request, exception): |
return render(request, 'app/404.html' , status = 404 ) |
#根目录新建urls.py 文件 |
urlpatterns = [ |
path( 'admin/' , admin.site.urls), |
path(' ',include(' users.urls')), |
path(' ',include(' app.urls')), |
] |
handler404 = "yournameapp.views.page_not_found_view" |
#settings.py文件 |
import os |
DEBUG = False |
TEMPLATES = [ |
{ |
'BACKEND' : |
'DIRS' : [os.path.join(BASE_DIR, 'templates' )], |
], |
}, |
}, |
] |