From 8b48a9b9bb37b711b7b1c3b12db86b526f65015f Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 10 Sep 2026 22:33:08 +0545 Subject: [PATCH] feat(templates): upgrade to Django 6.1 and MAILERS Require django>=6.1 in pyproject, bump ruff/pytest/pytest-django, point docs at 6.1, drop removed SECURE_BROWSER_XSS_FILTER and STATICFILES_STORAGE settings. Replace deprecated EMAIL_* settings with the Django 6.1 MAILERS dict. --- .../templates/config/settings/base.py-tpl | 7 +++--- .../config/settings/development.py-tpl | 10 +++++--- .../config/settings/production.py-tpl | 25 +++++++++++-------- .../templates/project/pyproject.toml-tpl | 8 +++--- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/djinit/templates/config/settings/base.py-tpl b/src/djinit/templates/config/settings/base.py-tpl index 02734cb..c45dbe8 100644 --- a/src/djinit/templates/config/settings/base.py-tpl +++ b/src/djinit/templates/config/settings/base.py-tpl @@ -17,7 +17,7 @@ environ.Env.read_env(env_path) BASE_DIR = Path(__file__).resolve().parent.parent.parent # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/6.1/howto/deployment/checklist/ # Application definition @@ -83,7 +83,7 @@ WSGI_APPLICATION = "[[ project_name ]].wsgi.application" # Password validation -# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/6.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -102,7 +102,7 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization -# https://docs.djangoproject.com/en/5.2/topics/i18n/ +# https://docs.djangoproject.com/en/6.1/topics/i18n/ LANGUAGE_CODE = "en-us" TIME_ZONE = "UTC" @@ -176,7 +176,6 @@ CORS_ALLOW_HEADERS = [ CORS_PREFLIGHT_MAX_AGE = 86400 # 24 hours # Security Settings -SECURE_BROWSER_XSS_FILTER = True SECURE_CONTENT_TYPE_NOSNIFF = True X_FRAME_OPTIONS = "DENY" diff --git a/src/djinit/templates/config/settings/development.py-tpl b/src/djinit/templates/config/settings/development.py-tpl index a90f21d..67f2349 100644 --- a/src/djinit/templates/config/settings/development.py-tpl +++ b/src/djinit/templates/config/settings/development.py-tpl @@ -10,7 +10,7 @@ DEBUG = True ALLOWED_HOSTS = ["*"] # Database -# https://docs.djangoproject.com/en/5.2/ref/settings/#databases +# https://docs.djangoproject.com/en/6.1/ref/settings/#databases DATABASES = { "default": { @@ -30,8 +30,12 @@ DATABASES = { } } -# Email backend for development -EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" +# Email settings for development +MAILERS = { + "default": { + "BACKEND": "django.core.mail.backends.console.EmailBackend", + }, +} # CORS settings for development # Allow all origins in development (convenient but not secure) diff --git a/src/djinit/templates/config/settings/production.py-tpl b/src/djinit/templates/config/settings/production.py-tpl index 1a6d84e..51c7851 100644 --- a/src/djinit/templates/config/settings/production.py-tpl +++ b/src/djinit/templates/config/settings/production.py-tpl @@ -43,14 +43,20 @@ CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_PRIVATE_NETWORK = False # Email settings -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -EMAIL_HOST = env('EMAIL_HOST', default="smtp.gmail.com") -EMAIL_PORT = env.int('EMAIL_PORT', default=587) -EMAIL_USE_TLS = env.bool('EMAIL_USE_TLS', default=True) -EMAIL_HOST_USER = env('EMAIL_HOST_USER', default="") -EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD', default="") -DEFAULT_FROM_EMAIL = env('EMAIL_HOST_USER', default="") -SERVER_EMAIL = env('EMAIL_HOST_USER', default="") +MAILERS = { + 'default': { + 'BACKEND': 'django.core.mail.backends.smtp.EmailBackend', + 'OPTIONS': { + 'host': env('EMAIL_HOST', default='smtp.gmail.com'), + 'port': env.int('EMAIL_PORT', default=587), + 'use_tls': env.bool('EMAIL_USE_TLS', default=True), + 'username': env('EMAIL_HOST_USER', default=''), + 'password': env('EMAIL_HOST_PASSWORD', default=''), + }, + }, +} +DEFAULT_FROM_EMAIL = env('EMAIL_HOST_USER', default='') +SERVER_EMAIL = env('EMAIL_HOST_USER', default='') # Security settings for production SECURE_SSL_REDIRECT = True @@ -63,9 +69,6 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True -# Static files -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' - # @IF use_tailwind ## Tailwind TAILWIND_CLI_VERSION = "4.1.3" # Pin version diff --git a/src/djinit/templates/project/pyproject.toml-tpl b/src/djinit/templates/project/pyproject.toml-tpl index b45f6ee..378f379 100644 --- a/src/djinit/templates/project/pyproject.toml-tpl +++ b/src/djinit/templates/project/pyproject.toml-tpl @@ -6,7 +6,7 @@ readme = "README.md" requires-python = ">=3.13" license = { text = "MIT" } dependencies = [ - "django", + "django>=6.1,<7.0", "django-environ", "django-jazzmin", "djangorestframework", @@ -37,9 +37,9 @@ dependencies = [ [dependency-groups] dev = [ - "ruff>=0.14.2", - "pytest>=8.0.0", - "pytest-django>=4.9.0", + "ruff>=0.16.6", + "pytest>=9.1.1", + "pytest-django>=4.14.0", ] [tool.ruff]