· 5 years ago · May 27, 2020, 02:12 AM
1"""
2Django settings for ecommerce project.
3
4Generated by 'django-admin startproject' using Django 1.11.22.
5
6For more information on this file, seepython run
7https://docs.djangoproject.com/en/1.11/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/1.11/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.dirname(os.path.abspath(__file__))))
17
18
19# Quick-start development settings - unsuitable for production
20# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
21
22# SECURITY WARNING: keep the secret key used in production secret!
23SECRET_KEY = '6)&0sjkb@r70qh1+8wx&-d964^ct63%h6yli!srenfnw)!$w*u'
24
25EMAIL_HOST = 'smtp.gmail.com'
26EMAIL_HOST_USER = 'sebasaade@gmail.com'
27EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
28EMAIL_PORT = 587
29EMAIL_USE_TLS = True
30DEFAULT_FROM_EMAIL = 'Python ecommerce <sebasaade@gmail.com>'
31
32
33MANAGERS = (
34 ('Sebastian Saade', "sebasaade@gmail.com"),
35)
36
37ADMINS = MANAGERS
38
39# SECURITY WARNING: don't run with debug turned on in production!
40DEBUG = True
41
42ALLOWED_HOSTS = ['.pythonecommerce.com']
43
44
45# Application definition
46
47INSTALLED_APPS = [
48 'django.contrib.admin',
49 'django.contrib.auth',
50 'django.contrib.contenttypes',
51 'django.contrib.sessions',
52 'django.contrib.messages',
53 'django.contrib.staticfiles',
54
55 #third party
56 'storages',
57
58 #our apps
59 'accounts',
60 'addresses',
61 'analytics',
62 'billing',
63 'carts',
64 'marketing',
65 'orders',
66 'products',
67 'search',
68 'tags',
69]
70
71AUTH_USER_MODEL = 'accounts.User' #change the built-in user model to ours
72LOGIN_URL = '/login/'
73LOGIN_URL_REDIRECT = '/'
74LOGOUT_URL = '/logout/'
75
76FORCE_SESSION_TO_ONE = False
77FORCE_INACTIVE_USER_ENDSESSION= False
78
79STRIPE_SECRET_KEY = "sk_test_wTb9XJsp9liBWK9IkvZgWbSH002h6jK919"
80STRIPE_PUB_KEY = "pk_test_yyXzNMv21Q2zBhLkFIATOO8y00Ed3O8Man"
81
82MAILCHIMP_API_KEY = "28ba5731efb222e60e95d70f63bb31a3-us4"
83MAILCHIMP_DATA_CENTER = 'us4'
84MAILCHIMP_EMAIL_LIST_ID ='c07c9d8c57'
85
86MIDDLEWARE = [
87 'django.middleware.security.SecurityMiddleware',
88 'django.contrib.sessions.middleware.SessionMiddleware',
89 'django.middleware.common.CommonMiddleware',
90 'django.middleware.csrf.CsrfViewMiddleware',
91 'django.contrib.auth.middleware.AuthenticationMiddleware',
92 'django.contrib.messages.middleware.MessageMiddleware',
93 'django.middleware.clickjacking.XFrameOptionsMiddleware',
94]
95
96LOGOUT_REDIRECT_URL = '/login/'
97ROOT_URLCONF = 'ecommerce.urls'
98
99TEMPLATES = [
100 {
101 'BACKEND': 'django.template.backends.django.DjangoTemplates',
102 'DIRS': [os.path.join(BASE_DIR, 'templates')],
103 'APP_DIRS': True,
104 'OPTIONS': {
105 'context_processors': [
106 'django.template.context_processors.debug',
107 'django.template.context_processors.request',
108 'django.contrib.auth.context_processors.auth',
109 'django.contrib.messages.context_processors.messages',
110 ],
111 },
112 },
113]
114
115WSGI_APPLICATION = 'ecommerce.wsgi.application'
116
117
118# Database
119# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
120
121DATABASES = {
122 'default': {
123 'ENGINE': 'django.db.backends.sqlite3',
124 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
125 }
126}
127
128# add this
129import dj_database_url
130db_from_env = dj_database_url.config() #postgreSQL Database in Heroku
131DATABASES['default'].update(db_from_env)
132DATABASES['default']['CONN_MAX_AGE'] = 500
133
134
135# Password validation
136# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
137
138AUTH_PASSWORD_VALIDATORS = [
139 {
140 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
141 },
142 {
143 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
144 },
145 {
146 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
147 },
148 {
149 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
150 },
151]
152
153
154# Internationalization
155# https://docs.djangoproject.com/en/1.11/topics/i18n/
156
157LANGUAGE_CODE = 'en-us'
158
159TIME_ZONE = 'UTC'
160
161USE_I18N = True
162
163USE_L10N = True
164
165USE_TZ = True
166
167
168# Static files (CSS, JavaScript, Images)
169# https://docs.djangoproject.com/en/1.11/howto/static-files/
170
171STATIC_URL = '/static/'
172
173STATICFILES_DIRS = [
174 os.path.join(BASE_DIR, "static_my_proj"),
175]
176
177STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn", "static_root")
178
179MEDIA_URL = '/media/'
180MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn", "media_root")
181
182from ecommerce.aws.conf import *
183
184#Let's Encrypt ssl/tls https
185
186CORS_REPLACE_HTTPS_REFERER = True
187HOST_SCHEME = "https://"
188SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
189SECURE_SSL_REDIRECT = True
190SESSION_COOKIE_SECURE = True
191CSRF_COOKIE_SECURE = True
192SECURE_HSTS_INCLUDE_SUBDOMAINS = True
193SECURE_HSTS_SECONDS = 1000000
194SECURE_FRAME_DENY = True
195
196AWS_DEFAULT_ACL = None