🔧 Split Settings into Development and Production Environments and updating the requirements#44
+155 −148
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves project configuration by splitting the Django settings into modular files for development and production environments. This structure follows best practices for environment-specific configuration and enhances maintainability, security, and developer experience.
Changes Introduced
📁 Created
settings/base.py: common settings shared across all environments.📁 Added
settings/development.py: tailored for local development.Enables DEBUG=TrueUses SQLite
Adds
localhosttoALLOWED_HOSTS📁 Added
settings/production.py: ready for deploymentSets
DEBUG=FalseUses
PostgreSQLwith environment variables viapython-decoupleImplements Django security best practices (HSTS, secure cookies, SSL redirects)
🔐 Improved use of decouple to load secrets and database config securely
🛡 Ensures
ALLOWED_HOSTSis explicitly set in all environments📦 Added
.env.exampleto guide contributors on environment setupWhy This Is Needed
Separating settings avoids accidental use of development configurations in production.
Prepares the Codespace for real-world deployment scenarios.
Supports cleaner, more secure environment management.
How to Test
Copy
.env.exampleto.envand populate required fields.Run development server with:
python manage.py runserver --settings=hello_world.settings.developmentTo simulate production locally:
python manage.py runserver --settings=hello_world.settings.productionNotes
This update is fully backward-compatible with existing
codespaceenvironment variables likeCODESPACE_NAME.Environment-specific settings now prevent misconfigurations during deployment.