Tommy D
Tommy D

Reputation: 418

Django - Debug set to True, when it is actually not

I have deployed my Django project on Ubuntu and I forgot to set the Debug to False till the very end, now I have pulled the last commit to the server with the debug set to False. So now when I try to access a non existing url, for example, it should display my custom 404.html template.

Instead it displays the Debug mode 404 error instead telling me that Debug = True even if it's not, I checked the settings.py file on the server and Debug is set to False.

I tried restarting nginx and supervisor with service nginx restart and supervisorctl restart my_app_name but when I enter a non existing url it still says that Debug is set to True.

Why does it still say that Debug is set to True?

UPDATE: following the answer received I went over the possible issues proposed and found none of them. Furthermore, when I run the exact same project on the local machine it works just fine with Debug = False.

If I run on the server the SAME EXACT project, with the same exact code and files/file structure (they are "synchronized" with github) it shows that the Debug is set to True, so there must be something related to the configuration on the server.

SECOND UPDATE: after adding a new domain in the ALLOWED_HOSTS list of the settings.py file, it is disregarding that as well. So it's not just a problem of the DEBUG variable, it is disregarding every change made to the settings.py file. Could it be Cloudfare Caching? If yes, what's a way to prevent this?

Upvotes: 1

Views: 1013

Answers (1)

user1600649
user1600649

Reputation:

Because it is. Common causes:

  • DEBUG=False and 30 lines later DEBUG=True
  • DJANGO_SETTINGS_FILE is pointing to a different file then you've changed the DEBUG setting in
  • on the bottom of the settings file another file, commonly named local_settings.py is imported and that has DEBUG=True
  • on the bottom of the settings file is some logic that imports environment variables overwriting previous definitions
  • DEBUG = 'False' # this is True

Upvotes: 1

Related Questions