Django2. 2 after installation, use runserver for development. When an error occurs, the error message is only displayed on the console command line, and only one line is displayed on the front page
“A server error occurred. Please contact the administrator.”
troubleshooting is very inconvenient. Check the error information on the console carefully and give a prompt
Unicode decodeerror: ‘GBK’ codec can’t decode byte 0xa6 in position 9737: ill…
it is judged that this version of Django cannot be displayed normally due to the code reading problem of the error message code
follow the prompts to find the python installation path\lib\site_packages\Django\views\debug.Py, after it is opened, the modification is about 332 lines, which will:
with Path(CURRENT_DIR, 'templates', 'technical_500.html').open() as fh:
Change to
with Path(CURRENT_DIR, 'templates', 'technical_500.html').open(encoding='utf-8') as fh:
That is, set the encoding, and then restart runserver. The error information can be displayed on the page normally.
Similar Posts:
- Django exception-ImportError: No module named django.core.management
- Django’36935;’21040;Invalid HTTP’u HOST header
- How to Solve Error: [Errno 11001] getaddrinfo failed
- ERRORS: ?: (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT set…
- Python2.7 Error: command not found: django-admin.py [How to Solve]
- Django startup error: generator expression must be parentized
- window.location And window.open The difference between
- Linux Implement Django Error: nohup: ignoring input and appending output to ‘nohup.out’
- ImportError: Couldn’t import Django [How to Solve]
- Docker Django: underlying buffer has been detached [How to Solve]