From 7281336bf31f28f5db710db836c67a207239b0fe Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 11 May 2026 00:51:11 +0545 Subject: [PATCH] feat(src/djinit/templates):add conditional django_q and celery applications and configurationAdd django_q and celery to project settings when feature flags are enabled, and provide default configuration values for both. Extend requirements template with corresponding dependencies. --- .../templates/config/settings/base.py-tpl | 29 +++++++++++++++++++ src/djinit/templates/project/requirements-tpl | 2 ++ 2 files changed, 31 insertions(+) diff --git a/src/djinit/templates/config/settings/base.py-tpl b/src/djinit/templates/config/settings/base.py-tpl index a880022..659d9ad 100644 --- a/src/djinit/templates/config/settings/base.py-tpl +++ b/src/djinit/templates/config/settings/base.py-tpl @@ -29,6 +29,8 @@ THIRD_PARTY_APPS = [ "django_tailwind_cli", # @IF use_tailwind "django_htmx", # @IF use_htmx "django_vite", # @IF use_vite | use_vue + "django_q", # @IF use_django_q + "celery", # @IF use_celery ] USER_DEFINED_APPS = [ @@ -235,3 +237,30 @@ STATIC_URL = "/static/" STATIC_ROOT = BASE_DIR / "staticfiles" STATICFILES_DIRS = [BASE_DIR / "static"] # @ENDIF + +# @IF use_django_q +# Django-Q2 configuration +Q_CLUSTER = { + "name": "djinit_project", + "workers": 4, + "max_threads": 30, + "timeout": 90, + "retry": 120, + "queue_limit": 50, + "bulk": 10, + "orm": "default", + "cache": "default", +} +# @ENDIF + +# @IF use_celery +# Celery configuration +CELERY_BROKER_URL = env("CELERY_BROKER_URL", default="redis://localhost:6379/0") +CELERY_RESULT_BACKEND = env("CELERY_RESULT_BACKEND", default="redis://localhost:6379/0") +CELERY_ACCEPT_CONTENT = ["json"] +CELERY_TASK_SERIALIZER = "json" +CELERY_RESULT_SERIALIZER = "json" +CELERY_TIMEZONE = TIME_ZONE +CELERY_TASK_TRACK_STARTED = True +CELERY_TASK_TIME_LIMIT = 30 * 60 +# @ENDIF diff --git a/src/djinit/templates/project/requirements-tpl b/src/djinit/templates/project/requirements-tpl index f654baf..305b9bd 100644 --- a/src/djinit/templates/project/requirements-tpl +++ b/src/djinit/templates/project/requirements-tpl @@ -17,6 +17,8 @@ django-vite # @IF use_vue pytest # @IF use_pytest pytest-django # @IF use_pytest pytest-cov # @IF use_pytest +django-q2 # @IF use_django_q +celery # @IF use_celery # @IF database_type == 'mysql' mysqlclient # @ELSE