简体   繁体   中英

How do I set my django debug=False and show 404 on the web when there is error?

My settings.py code:

SECRET_KEY = os.environ['SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False'

My .bash_profile:

# Django test deploy
 export SECRET_KEY='67bd6db221e2be1b5b16cb70b79d3bbee8928d9053a8eb32'
 export DJANGO_DEBUG="False"

There is no default 404 page. You first create a 404 template and respective view. After which in urls.py you add

handler404 = 'mysite.views.my_custom_page_not_found_view'

This is for page not found error, for other error codes like 500,etc do accordingly. Read the official documentation here https://docs.djangoproject.com/en/3.0/topics/http/views/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM