Introduction
This article will inform on how to set or to configure about how to set the DEBUG from True to False in a Django-based application. It is very easy to do it since in Django-based application, the configuration for the Django-based application is in a single file. It exist in a file with the name of ‘settings.py’. Normally, it exist in the folder of the Django project. But if there is some sort of modification on the project, it will not exist in that folder. For an example, if there is a project with the name of ‘djangoproject’, by default it will exist in a folder with the name of ‘djangoproject’ inside of it. The following is an example to show it :
(env) C:\repository\django>django-admin startproject myproject (env) C:\repository\django>cd myproject (env) C:\repository\django\myproject>dir Volume in drive C is Windows-SSD Volume Serial Number is CA30-19A4 Directory of C:\repository\django\myproject> 07/22/2022 09:11 AM <DIR> . 07/22/2022 09:11 AM <DIR> .. 07/22/2022 09:11 AM 687 manage.py 07/22/2022 09:11 AM <DIR> myproject 1 File(s) 687 bytes 3 Dir(s) 141,223,841,792 bytes free (env) C:\repository\django\myproject>cd myproject (env) C:\repository\django\myproject\myproject>dir Volume in drive C is Windows-SSD Volume Serial Number is CA30-19A4 Directory of C:\repository\django\myproject\myproject 07/22/2022 09:11 AM <DIR> . 07/22/2022 09:11 AM <DIR> .. 07/22/2022 09:11 AM 411 asgi.py 07/22/2022 09:11 AM 3,353 settings.py 07/22/2022 09:11 AM 772 urls.py 07/22/2022 09:11 AM 411 wsgi.py 07/22/2022 09:11 AM 0 __init__.py 5 File(s) 4,947 bytes 2 Dir(s) 141,223,723,008 bytes free (env) C:\repository\django\myproject\myproject>
How to Set DEBUG to False for Django Application
So, in order to change the DEBUG configuration from True to False, just follow the steps below :
-
First of all, just open the file with the name of ‘settings.py’.
-
After that, search for the DEBUG configuration in the file. The following is the original DEBUG configuration in the file :
# SECURITY WARNING: don't run with debug turned on in production! DEBUG = True
-
Change the value of the above DEBUG configuration as follows :
# SECURITY WARNING: don't run with debug turned on in production! DEBUG = False
- In order to take the effect, every changes in the ‘settings.py’ must be followed by restarting the Django application’s service. The DEBUG settings with the ‘False’ value is very useful to hide all of the error information. So, if there is an error message, the following display will appear as an example :