About Default DJANGO_SETTINGS_MODULE

If you use multiple Django project settings files for different environments (dev, test, staging, production), then better remove the following line from manage.py, wsgi.py, and asgi.py:

1
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings')

This will force you to always set the DJANGO_SETTINGS_MODULE environment variable or a custom --settings parameter and will save you from unwanted behavior (like migrating a wrong database) when you mismatch the environments.

Tips and Tricks Programming Dev Ops Django 4.2 Django 3.2