· 5 years ago · Dec 27, 2019, 03:36 AM
1"""
2Django settings for cde project.
3
4Generated by 'django-admin startproject' using Django 2.2.9.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.2/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.2/ref/settings/
11"""
12
13import os
14
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
18# Quick-start development settings - unsuitable for production
19# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
20
21# SECURITY WARNING: keep the secret key used in production secret!
22SECRET_KEY = 'w1zxu3_8)jmsb=kt_x!n)^(i@#tv2p$4xs5k=xe%*z^w8(m3!o'
23
24# SECURITY WARNING: don't run with debug turned on in production!
25DEBUG = False
26
27ALLOWED_HOSTS = [
28    "*"
29]
30
31# Application definition
32
33INSTALLED_APPS = [
34    'django.contrib.admin',
35    'django.contrib.auth',
36    'django.contrib.contenttypes',
37    'django.contrib.sessions',
38    'django.contrib.messages',
39    'django.contrib.staticfiles',
40    'corsheaders'
41]
42
43MIDDLEWARE = [
44    'django.middleware.security.SecurityMiddleware',
45    'django.contrib.sessions.middleware.SessionMiddleware',
46    'corsheaders.middleware.CorsMiddleware',
47    'django.middleware.common.CommonMiddleware',
48    # 'django.middleware.csrf.CsrfViewMiddleware',
49    'django.contrib.auth.middleware.AuthenticationMiddleware',
50    'django.contrib.messages.middleware.MessageMiddleware',
51    'django.middleware.clickjacking.XFrameOptionsMiddleware',
52]
53
54ROOT_URLCONF = 'cde.urls'
55
56TEMPLATES = [
57    {
58        'BACKEND': 'django.template.backends.django.DjangoTemplates',
59        'DIRS': [os.path.join(BASE_DIR, 'templates')],
60        'APP_DIRS': True,
61        'OPTIONS': {
62            'context_processors': [
63                'django.template.context_processors.debug',
64                'django.template.context_processors.request',
65                'django.contrib.auth.context_processors.auth',
66                'django.contrib.messages.context_processors.messages',
67            ],
68        },
69    },
70]
71
72WSGI_APPLICATION = 'cde.wsgi.application'
73
74# Database
75# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
76
77DATABASES = {
78    'default': {
79        'ENGINE': 'django.db.backends.postgresql',
80        'NAME': os.getenv('POSTGRES_DB'),
81        'HOST': os.getenv('POSTGRES_HOST'),
82        'USER': os.getenv('POSTGRES_USER'),
83        'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
84        'PORT': os.getenv('POSTGRES_PORT'),
85    }
86}
87
88# Password validation
89# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
90
91AUTH_PASSWORD_VALIDATORS = [
92    {
93        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
94    },
95    {
96        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
97    },
98    {
99        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
100    },
101    {
102        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
103    },
104]
105
106# Internationalization
107# https://docs.djangoproject.com/en/2.2/topics/i18n/
108
109LANGUAGE_CODE = 'en-us'
110
111TIME_ZONE = 'UTC'
112
113USE_I18N = True
114
115USE_L10N = True
116
117USE_TZ = True
118
119# Static files (CSS, JavaScript, Images)
120# https://docs.djangoproject.com/en/2.2/howto/static-files/
121
122STATIC_URL = '/static/'
123
124STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
125
126STATICFILES_DIRS = [
127    os.path.join(BASE_DIR, "static"),
128]
129
130# Media files
131MEDIA_URL = '/media/'
132
133MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")
134
135CORS_ORIGIN_ALLOW_ALL = True