|
1 |
| -""" |
2 |
| -Django settings for config project. |
3 |
| -
|
4 |
| -Generated by 'django-admin startproject' using Django 4.0. |
5 |
| -
|
6 |
| -For more information on this file, see |
7 |
| -https://docs.djangoproject.com/en/4.0/topics/settings/ |
8 |
| -
|
9 |
| -For the full list of settings and their values, see |
10 |
| -https://docs.djangoproject.com/en/4.0/ref/settings/ |
11 |
| -""" |
12 |
| - |
13 |
| -from pathlib import Path |
| 1 | +import os |
14 | 2 | from decouple import config
|
15 | 3 |
|
16 |
| -# Build paths inside the project like this: BASE_DIR / 'subdir'. |
17 |
| -BASE_DIR = Path(__file__).resolve().parent.parent |
18 | 4 |
|
19 | 5 |
|
20 |
| -# Quick-start development settings - unsuitable for production |
21 |
| -# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ |
22 |
| - |
23 |
| -# SECURITY WARNING: keep the secret key used in production secret! |
24 |
| -SECRET_KEY = config('SECRET_KEY') |
25 |
| - |
26 |
| -# SECURITY WARNING: don't run with debug turned on in production! |
27 |
| -DEBUG = True # We will turn this to false when have auto backend deployment |
28 |
| - |
29 |
| -ALLOWED_HOSTS = [] |
| 6 | +DEBUG = True |
30 | 7 |
|
| 8 | +USE_TZ = True |
31 | 9 |
|
32 |
| -# Application definition |
| 10 | +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
33 | 11 |
|
34 |
| -INSTALLED_APPS = [ |
35 |
| - 'django.contrib.admin', |
36 |
| - 'django.contrib.auth', |
37 |
| - 'django.contrib.contenttypes', |
38 |
| - 'django.contrib.sessions', |
39 |
| - 'django.contrib.messages', |
40 |
| - 'django.contrib.staticfiles', |
41 |
| - 'rest_framework', |
42 |
| - 'livereload', |
43 |
| - 'api.apps.ApiConfig', |
44 |
| - 'corsheaders', |
45 |
| -] |
46 |
| - |
47 |
| -MIDDLEWARE = [ |
48 |
| - 'corsheaders.middleware.CorsMiddleware', |
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 |
| - 'livereload.middleware.LiveReloadScript', |
57 |
| -] |
| 12 | +USE_I18N = True |
58 | 13 |
|
59 |
| -ROOT_URLCONF = 'config.urls' |
| 14 | +USE_L10N = True |
| 15 | + |
| 16 | +DATABASES = { |
| 17 | + 'default': { |
| 18 | + 'HOST': config('DB_HOST'), |
| 19 | + 'NAME': config('DB_NAME'), |
| 20 | + 'PORT': config('DB_PORT'), |
| 21 | + 'USER': config('DB_USER'), |
| 22 | + 'ENGINE': "django.db.backends.postgresql_psycopg2", |
| 23 | + 'PASSWORD': config('DB_PASSWORD'), |
| 24 | + } |
| 25 | +} |
60 | 26 |
|
61 | 27 | TEMPLATES = [
|
62 |
| - { |
63 |
| - 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
64 |
| - 'DIRS': [], |
65 |
| - 'APP_DIRS': True, |
66 |
| - 'OPTIONS': { |
67 |
| - 'context_processors': [ |
68 |
| - 'django.template.context_processors.debug', |
69 |
| - 'django.template.context_processors.request', |
70 |
| - 'django.contrib.auth.context_processors.auth', |
71 |
| - 'django.contrib.messages.context_processors.messages', |
72 |
| - ], |
73 |
| - }, |
74 |
| - }, |
| 28 | + { |
| 29 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 30 | + 'DIRS': [], |
| 31 | + 'APP_DIRS': True, |
| 32 | + 'OPTIONS': { |
| 33 | + 'context_processors': [ |
| 34 | + 'django.template.context_processors.debug', |
| 35 | + 'django.template.context_processors.request', |
| 36 | + 'django.contrib.auth.context_processors.auth', |
| 37 | + 'django.contrib.messages.context_processors.messages', |
| 38 | + ] |
| 39 | + } |
| 40 | + } |
75 | 41 | ]
|
76 | 42 |
|
77 |
| -WSGI_APPLICATION = 'config.wsgi.application' |
78 |
| - |
79 |
| - |
80 |
| -# Database |
81 |
| -# https://docs.djangoproject.com/en/4.0/ref/settings/#databases |
| 43 | +TIME_ZONE = 'UTC' |
82 | 44 |
|
83 |
| -# DATABASES = { |
84 |
| -# 'default': { |
85 |
| -# 'ENGINE': 'django.db.backends.sqlite3', |
86 |
| -# 'NAME': BASE_DIR / 'db.sqlite3', |
87 |
| -# } |
88 |
| -# } |
| 45 | +MIDDLEWARE = [ |
| 46 | + 'django.middleware.security.SecurityMiddleware', |
| 47 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 48 | + 'corsheaders.middleware.CorsMiddleware', |
| 49 | + 'django.middleware.common.CommonMiddleware', |
| 50 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 51 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 52 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 53 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 54 | +] |
89 | 55 |
|
| 56 | +# SECURITY WARNING: keep the secret key used in production secret! |
| 57 | +SECRET_KEY = config('SECRET_KEY') |
90 | 58 |
|
91 |
| -# Password validation |
92 |
| -# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators |
93 |
| - |
94 |
| -AUTH_PASSWORD_VALIDATORS = [ |
95 |
| - { |
96 |
| - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', |
97 |
| - }, |
98 |
| - { |
99 |
| - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', |
100 |
| - }, |
101 |
| - { |
102 |
| - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', |
103 |
| - }, |
104 |
| - { |
105 |
| - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', |
106 |
| - }, |
107 |
| -] |
| 59 | +STATIC_URL = '/static/' |
108 | 60 |
|
| 61 | +ROOT_URLCONF = 'config.urls' |
109 | 62 |
|
110 |
| -# Internationalization |
111 |
| -# https://docs.djangoproject.com/en/4.0/topics/i18n/ |
| 63 | +ALLOWED_HOSTS = ['*'] |
112 | 64 |
|
113 | 65 | LANGUAGE_CODE = 'en-us'
|
114 | 66 |
|
115 |
| -TIME_ZONE = 'UTC' |
116 |
| - |
117 |
| -USE_I18N = True |
| 67 | +INSTALLED_APPS = [ |
| 68 | + 'django.contrib.admin', |
| 69 | + 'django.contrib.auth', |
| 70 | + 'django.contrib.contenttypes', |
| 71 | + 'django.contrib.sessions', |
| 72 | + 'django.contrib.messages', |
| 73 | + 'django.contrib.staticfiles', |
| 74 | + 'corsheaders', |
| 75 | + 'rest_framework', |
| 76 | +] |
118 | 77 |
|
119 |
| -USE_TZ = True |
| 78 | +WSGI_APPLICATION = 'config.wsgi.application' |
120 | 79 |
|
| 80 | +AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID') |
| 81 | + |
| 82 | +CORS_ALLOW_HEADERS = [ |
| 83 | + 'x-requested-with', |
| 84 | + 'content-type', |
| 85 | + 'accept', |
| 86 | + 'origin', |
| 87 | + 'authorization', |
| 88 | + 'accept-encoding', |
| 89 | + 'x-csrftoken', |
| 90 | + 'access-control-allow-origin', |
| 91 | + 'content-disposition', |
| 92 | +] |
121 | 93 |
|
122 |
| -# Static files (CSS, JavaScript, Images) |
123 |
| -# https://docs.djangoproject.com/en/4.0/howto/static-files/ |
| 94 | +CORS_ALLOW_METHODS = [ |
| 95 | + 'GET', |
| 96 | + 'POST', |
| 97 | + 'PUT', |
| 98 | + 'PATCH', |
| 99 | + 'DELETE', |
| 100 | + 'OPTIONS', |
| 101 | +] |
124 | 102 |
|
| 103 | +AWS_S3_CUSTOM_DOMAIN = f'{config("AWS_STORAGE_BUCKET_NAME")}.s3.amazonaws.com' |
125 | 104 |
|
126 |
| -STATIC_URL = 'static/' |
| 105 | +DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' |
127 | 106 |
|
128 |
| -# Default primary key field type |
129 |
| -# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field |
| 107 | +AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY') |
130 | 108 |
|
131 |
| -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
| 109 | +CORS_ORIGIN_ALLOW_ALL = True |
132 | 110 |
|
133 |
| -# CORS_ALLOWED_ORIGINS = config('FRONTEND_URL').split(" ") |
134 |
| -# CORS_ORIGIN_WHITELIST = config('FRONTEND_URL').split(" ") |
| 111 | +CORS_ALLOW_CREDENTIALS = False |
135 | 112 |
|
136 |
| -REST_FRAMEWORK = { |
137 |
| - 'DEFAULT_AUTHENTICATION_CLASSES': [], |
138 |
| - 'DEFAULT_PERMISSION_CLASSES': [], |
139 |
| -} |
| 113 | +AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME') |
140 | 114 |
|
141 |
| -# CSRF_TRUSTED_ORIGINS = config('FRONTEND_URL').split(" ") |
| 115 | +AUTH_PASSWORD_VALIDATORS = [ |
| 116 | + {'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, |
| 117 | + {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'}, |
| 118 | + {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}, |
| 119 | + {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'}, |
| 120 | +] |
0 commit comments