From 0cff748d5e5c49e31f636f6c4e919f33f0a18eb0 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 31 Jan 2026 02:48:32 +0545 Subject: [PATCH] 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. --- djinit/templates/config/settings/production.py-tpl | 4 ++-- djinit/templates/project/env_sample-tpl | 4 ++-- djinit/templates/project/readme.md-tpl | 4 ++-- djinit/templates/project/requirements-tpl | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/djinit/templates/config/settings/production.py-tpl b/djinit/templates/config/settings/production.py-tpl index 72d0c42..7d58363 100644 --- a/djinit/templates/config/settings/production.py-tpl +++ b/djinit/templates/config/settings/production.py-tpl @@ -8,7 +8,7 @@ SECRET_KEY = env('SECRET_KEY') ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=[]) # Database -# @IF use_database_url +# @IF use_database_url # Using dj_database_url (recommended for production) DATABASES = { 'default': env.db('DATABASE_URL') @@ -17,7 +17,7 @@ DATABASES = { # Using individual database parameters DATABASES = { 'default': { - # @IF database_type == 'mysql' + # @IF database_type == 'mysql' 'ENGINE': 'django.db.backends.mysql', 'PORT': env('DB_PORT', default='3306'), # @ELSE diff --git a/djinit/templates/project/env_sample-tpl b/djinit/templates/project/env_sample-tpl index 65d6da7..382da28 100644 --- a/djinit/templates/project/env_sample-tpl +++ b/djinit/templates/project/env_sample-tpl @@ -3,9 +3,9 @@ DJANGO_SETTINGS_MODULE=[[ project_name ]].settings.development SECRET_KEY= your-secret-key ALLOWED_HOSTS=api.your-domain.com,www.your-domain.com -# @IF use_database_url +# @IF use_database_url # Database URL (recommended for production) -# @IF database_type == 'mysql' +# @IF database_type == 'mysql' DATABASE_URL=mysql://user:password@localhost:3306/[[ project_name ]] # @ELSE DATABASE_URL=postgres://user:password@localhost:5432/[[ project_name ]] diff --git a/djinit/templates/project/readme.md-tpl b/djinit/templates/project/readme.md-tpl index c107ade..9c28632 100644 --- a/djinit/templates/project/readme.md-tpl +++ b/djinit/templates/project/readme.md-tpl @@ -71,7 +71,7 @@ Run `just` to see all available commands, including: ## Project Structure ``` -# @IF predefined_structure +# @IF predefined_structure [[ project_name ]]/ ├── [[ module_name ]]/ │ ├── settings/ @@ -118,7 +118,7 @@ Run `just` to see all available commands, including: ├── Procfile ├── runtime.txt └── README.md -# @ELSEIF unified_structure +# @ELSEIF unified_structure [[ project_name ]]/ ├── apps/ │ ├── admin/ diff --git a/djinit/templates/project/requirements-tpl b/djinit/templates/project/requirements-tpl index 43aee21..cb48ff9 100644 --- a/djinit/templates/project/requirements-tpl +++ b/djinit/templates/project/requirements-tpl @@ -10,7 +10,7 @@ djangorestframework_simplejwt drf-spectacular django-cors-headers whitenoise -# @IF database_type == 'mysql' +# @IF database_type == 'mysql' mysqlclient # @ELSE psycopg[binary]