1
1
"""
2
2
Django settings for django_celery_example project.
3
3
4
- Generated by 'django-admin startproject' using Django 3.2.9 .
4
+ Generated by 'django-admin startproject' using Django 4.0.7 .
5
5
6
6
For more information on this file, see
7
- https://docs.djangoproject.com/en/3.2 /topics/settings/
7
+ https://docs.djangoproject.com/en/4.0 /topics/settings/
8
8
9
9
For the full list of settings and their values, see
10
- https://docs.djangoproject.com/en/3.2 /ref/settings/
10
+ https://docs.djangoproject.com/en/4.0 /ref/settings/
11
11
"""
12
12
import os
13
13
14
14
from pathlib import Path
15
+
15
16
from kombu import Queue
16
17
17
18
# Build paths inside the project like this: BASE_DIR / 'subdir'.
18
19
BASE_DIR = Path (__file__ ).resolve ().parent .parent
19
20
20
21
21
22
# Quick-start development settings - unsuitable for production
22
- # See https://docs.djangoproject.com/en/3.2 /howto/deployment/checklist/
23
+ # See https://docs.djangoproject.com/en/4.0 /howto/deployment/checklist/
23
24
25
+ # SECURITY WARNING: keep the secret key used in production secret!
24
26
SECRET_KEY = os .environ .get ("SECRET_KEY" , "&nl8s430j^j8l*je+m&ys5dv#zoy)0a2+x1!m8hx290_sx&0gh" )
25
27
28
+ # SECURITY WARNING: don't run with debug turned on in production!
26
29
DEBUG = int (os .environ .get ("DEBUG" , default = 1 ))
27
30
28
31
ALLOWED_HOSTS = os .environ .get ("DJANGO_ALLOWED_HOSTS" , "127.0.0.1" ).split (" " )
74
77
# WSGI_APPLICATION = 'django_celery_example.wsgi.application'
75
78
ASGI_APPLICATION = 'django_celery_example.asgi.application'
76
79
77
-
78
80
# Database
79
- # https://docs.djangoproject.com/en/3.2 /ref/settings/#databases
81
+ # https://docs.djangoproject.com/en/4.0 /ref/settings/#databases
80
82
81
83
DATABASES = {
82
84
"default" : {
91
93
92
94
93
95
# Password validation
94
- # https://docs.djangoproject.com/en/3.2 /ref/settings/#auth-password-validators
96
+ # https://docs.djangoproject.com/en/4.0 /ref/settings/#auth-password-validators
95
97
96
98
AUTH_PASSWORD_VALIDATORS = [
97
99
{
110
112
111
113
112
114
# Internationalization
113
- # https://docs.djangoproject.com/en/3.2 /topics/i18n/
115
+ # https://docs.djangoproject.com/en/4.0 /topics/i18n/
114
116
115
117
LANGUAGE_CODE = 'en-us'
116
118
117
119
TIME_ZONE = 'UTC'
118
120
119
121
USE_I18N = True
120
122
121
- USE_L10N = True
122
-
123
123
USE_TZ = True
124
124
125
125
126
126
# Static files (CSS, JavaScript, Images)
127
- # https://docs.djangoproject.com/en/3.2 /howto/static-files/
127
+ # https://docs.djangoproject.com/en/4.0 /howto/static-files/
128
128
129
- STATIC_URL = '/ static/'
129
+ STATIC_URL = 'static/'
130
130
STATIC_ROOT = os .path .join (BASE_DIR , 'staticfiles' )
131
131
132
+ # where Django hold upload files
133
+ MEDIA_URL = '/media/'
134
+ MEDIA_ROOT = os .path .join (BASE_DIR , 'mediafiles' )
135
+
132
136
# Default primary key field type
133
- # https://docs.djangoproject.com/en/3.2 /ref/settings/#default-auto-field
137
+ # https://docs.djangoproject.com/en/4.0 /ref/settings/#default-auto-field
134
138
135
139
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
136
140
137
- MEDIA_URL = '/media/'
138
- MEDIA_ROOT = os .path .join (BASE_DIR , 'mediafiles' )
141
+ ################################################################################
139
142
140
143
CELERY_BROKER_URL = os .environ .get ("CELERY_BROKER" , "redis://127.0.0.1:6379/0" )
141
144
CELERY_RESULT_BACKEND = os .environ .get ("CELERY_BACKEND" , "redis://127.0.0.1:6379/0" )
149
152
},
150
153
}
151
154
155
+
152
156
CELERY_BEAT_SCHEDULE = {
153
157
# 'task-clear-session': {
154
158
# 'task': 'task_clear_session',
155
159
# "schedule": 5.0, # five seconds
156
160
# },
157
161
}
158
162
163
+
159
164
CELERY_TASK_DEFAULT_QUEUE = 'default'
160
165
161
166
# Force all queues to be explicitly listed in `CELERY_TASK_QUEUES` to help prevent typos
169
174
Queue ('low_priority' ),
170
175
)
171
176
172
- # manual task routing
173
177
174
178
# CELERY_TASK_ROUTES = {
175
179
# 'django_celery_example.celery.*': {
@@ -187,3 +191,4 @@ def route_task(name, args, kwargs, options, task=None, **kw):
187
191
188
192
189
193
CELERY_TASK_ROUTES = (route_task ,)
194
+
0 commit comments