|
10 | 10 | https://docs.djangoproject.com/en/3.2/ref/settings/
|
11 | 11 | """
|
12 | 12 |
|
| 13 | +import os # <-- NEW: used by BASE_DIR definition |
13 | 14 | from pathlib import Path
|
14 | 15 |
|
15 | 16 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
37 | 38 | 'django.contrib.sessions',
|
38 | 39 | 'django.contrib.messages',
|
39 | 40 | 'django.contrib.staticfiles',
|
| 41 | + 'django_tm', # Django Tasks Manager # <-- NEW |
| 42 | + 'django_celery_results', # Django Celery Results # <-- NEW |
40 | 43 | ]
|
41 | 44 |
|
42 | 45 | MIDDLEWARE = [
|
|
51 | 54 |
|
52 | 55 | ROOT_URLCONF = 'core.urls'
|
53 | 56 |
|
| 57 | +TEMPLATE_DIR_TASKS = os.path.join(BASE_DIR, "django_tm/templates") # <-- NEW |
| 58 | + |
54 | 59 | TEMPLATES = [
|
55 | 60 | {
|
56 | 61 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
57 |
| - 'DIRS': [], |
| 62 | + 'DIRS': [TEMPLATE_DIR_TASKS], # <-- UPDATED |
58 | 63 | 'APP_DIRS': True,
|
59 | 64 | 'OPTIONS': {
|
60 | 65 | 'context_processors': [
|
|
123 | 128 | # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
124 | 129 |
|
125 | 130 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
| 131 | + |
| 132 | +############################################################# |
| 133 | +# Django & Celery configurations |
| 134 | +# |
| 135 | +# BASE_DIR points to the ROOT of the project |
| 136 | +# Note: make sure you have 'os' object imported |
| 137 | +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) |
| 138 | + |
| 139 | +# Working Directories required write permission |
| 140 | +CELERY_SCRIPTS_DIR = os.path.join(BASE_DIR, "celery_scripts" ) |
| 141 | +CELERY_LOGS_DIR = os.path.join(BASE_DIR, "celery_logs" ) |
| 142 | + |
| 143 | +CELERY_BROKER_URL = os.environ.get("CELERY_BROKER", "redis://localhost:6379") |
| 144 | +CELERY_RESULT_BACKEND = os.environ.get("CELERY_BROKER", "redis://localhost:6379") |
| 145 | + |
| 146 | +CELERY_TASK_TRACK_STARTED = True |
| 147 | +CELERY_TASK_TIME_LIMIT = 30 * 60 |
| 148 | +CELERY_CACHE_BACKEND = "django-cache" |
| 149 | +CELERY_RESULT_BACKEND = "django-db" |
| 150 | +CELERY_RESULT_EXTENDED = True |
| 151 | +CELERY_RESULT_EXPIRES = 60*60*24*30 # Results expire after 1 month |
| 152 | +CELERY_ACCEPT_CONTENT = ["json"] |
| 153 | +CELERY_TASK_SERIALIZER = 'json' |
| 154 | +CELERY_RESULT_SERIALIZER = 'json' |
| 155 | + |
| 156 | +############################################################# |
| 157 | +############################################################# |
0 commit comments