· 5 years ago · Aug 02, 2020, 03:30 PM
1"""
2Django settings for core project.
3
4Generated by 'django-admin startproject' using Django 3.0.4.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/3.0/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/3.0/ref/settings/
11"""
12
13import os
14from celery.schedules import crontab
15
16import core.tasks
17
18
19# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
20BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
21
22
23# Quick-start development settings - unsuitable for production
24# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
25
26SECRET_KEY = os.environ.get("SECRET_KEY")
27
28DEBUG = int(os.environ.get("DEBUG", default=0))
29
30# 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each.
31# For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]'
32ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")
33
34
35# Application definition
36
37INSTALLED_APPS = [
38 "django.contrib.admin",
39 "django.contrib.auth",
40 "django.contrib.contenttypes",
41 "django.contrib.sessions",
42 "django.contrib.messages",
43 "django.contrib.staticfiles",
44 "orders.apps.OrdersConfig",
45 "performance.apps.PerformanceConfig",
46]
47
48MIDDLEWARE = [
49 "django.middleware.security.SecurityMiddleware",
50 "django.contrib.sessions.middleware.SessionMiddleware",
51 "django.middleware.common.CommonMiddleware",
52 "django.middleware.csrf.CsrfViewMiddleware",
53 "django.contrib.auth.middleware.AuthenticationMiddleware",
54 "django.contrib.messages.middleware.MessageMiddleware",
55 "django.middleware.clickjacking.XFrameOptionsMiddleware",
56]
57
58ROOT_URLCONF = "core.urls"
59
60TEMPLATES = [
61 {
62 "BACKEND": "django.template.backends.django.DjangoTemplates",
63 "DIRS": [os.path.join(BASE_DIR, "templates")],
64 "APP_DIRS": True,
65 "OPTIONS": {
66 "context_processors": [
67 "django.template.context_processors.debug",
68 "django.template.context_processors.request",
69 "django.contrib.auth.context_processors.auth",
70 "django.contrib.messages.context_processors.messages",
71 ],
72 },
73 },
74]
75
76WSGI_APPLICATION = "core.wsgi.application"
77
78
79# Database
80# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
81
82DATABASES = {
83 "default": {
84 "ENGINE": "django.db.backends.sqlite3",
85 "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
86 }
87}
88
89
90# Password validation
91# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
92
93AUTH_PASSWORD_VALIDATORS = [
94 {
95 "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
96 },
97 {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
98 {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
99 {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
100]
101
102
103# Internationalization
104# https://docs.djangoproject.com/en/3.0/topics/i18n/
105
106LANGUAGE_CODE = "en-us"
107
108TIME_ZONE = "UTC"
109
110USE_I18N = True
111
112USE_L10N = True
113
114USE_TZ = True
115
116
117# Static files (CSS, JavaScript, Images)
118# https://docs.djangoproject.com/en/3.0/howto/static-files/
119
120STATIC_URL = "/staticfiles/"
121STATIC_ROOT = ""
122
123# Celery Brocker
124CELERY_BROKER_URL = "redis://redis:6379"
125CELERY_RESULT_BACKEND = "redis://redis:6379"
126
127CELERY_BEAT_SCHEDULE = {
128 "test_task": {
129 "task": "core.tasks.my_first_task",
130 "schedule": crontab(minute="*/1"),
131 },
132 "database_task": {
133 "task": "core.tasks.put_in_table_task",
134 "schedule": crontab(minute="*/1"),
135 },
136 "task_with_database" : {
137 "task" : "performance.tasks.task_with_database",
138 "schedule" : crontab(minute="*/1"),
139 }
140}