feat(djinit/templates): Refine template placeholders for production and environment configuration files

Added conditional comment handling for database settings in production template, introduced DATABASE_URL generation in env_sample, and corrected readme structure rendering.

New Features
- Added conditional comment handling for `use_database_url` and `database_type` in production settings.
- Added `DATABASE_URL` template logic for MySQL and PostgreSQL in env_sample.
- Updated `readme.md` template to properly render unified_structure sections.

Enhancements
- Ensured comment syntax consistency across all template files.
- Streamlined placeholder usage for clearer project scaffolding.

Bug Fixes
- Removed stray formatting characters from comment markers.
This commit is contained in:
sankalp committed 2026-01-31 02:48:32 +05:45
1 parent 85981115ce
commit 0cff748d5e
4 files changed
+7 -7

No files matched your search

@@ -8,7 +8,7 @@ SECRET_KEY = env('SECRET_KEY')
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=[]) ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=[])
# Database # Database
# @IF use_database_url # @IF use_database_url
# Using dj_database_url (recommended for production) # Using dj_database_url (recommended for production)
DATABASES = { DATABASES = {
'default': env.db('DATABASE_URL') 'default': env.db('DATABASE_URL')
@@ -17,7 +17,7 @@ DATABASES = {
# Using individual database parameters # Using individual database parameters
DATABASES = { DATABASES = {
'default': { 'default': {
# @IF database_type == 'mysql' # @IF database_type == 'mysql'
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'PORT': env('DB_PORT', default='3306'), 'PORT': env('DB_PORT', default='3306'),
# @ELSE # @ELSE
+2 -2
View File
@@ -3,9 +3,9 @@ DJANGO_SETTINGS_MODULE=[[ project_name ]].settings.development
SECRET_KEY= your-secret-key SECRET_KEY= your-secret-key
ALLOWED_HOSTS=api.your-domain.com,www.your-domain.com ALLOWED_HOSTS=api.your-domain.com,www.your-domain.com
# @IF use_database_url # @IF use_database_url
# Database URL (recommended for production) # Database URL (recommended for production)
# @IF database_type == 'mysql' # @IF database_type == 'mysql'
DATABASE_URL=mysql://user:password@localhost:3306/[[ project_name ]] DATABASE_URL=mysql://user:password@localhost:3306/[[ project_name ]]
# @ELSE # @ELSE
DATABASE_URL=postgres://user:password@localhost:5432/[[ project_name ]] DATABASE_URL=postgres://user:password@localhost:5432/[[ project_name ]]
+2 -2
View File
@@ -71,7 +71,7 @@ Run `just` to see all available commands, including:
## Project Structure ## Project Structure
``` ```
# @IF predefined_structure # @IF predefined_structure
[[ project_name ]]/ [[ project_name ]]/
├── [[ module_name ]]/ ├── [[ module_name ]]/
│ ├── settings/ │ ├── settings/
@@ -118,7 +118,7 @@ Run `just` to see all available commands, including:
├── Procfile ├── Procfile
├── runtime.txt ├── runtime.txt
└── README.md └── README.md
# @ELSEIF unified_structure # @ELSEIF unified_structure
[[ project_name ]]/ [[ project_name ]]/
├── apps/ ├── apps/
│ ├── admin/ │ ├── admin/
+1 -1
View File
@@ -10,7 +10,7 @@ djangorestframework_simplejwt
drf-spectacular drf-spectacular
django-cors-headers django-cors-headers
whitenoise whitenoise
# @IF database_type == 'mysql' # @IF database_type == 'mysql'
mysqlclient mysqlclient
# @ELSE # @ELSE
psycopg[binary] psycopg[binary]