· 10 years ago · Apr 13, 2016, 05:12 PM
1"""
2Django settings for gettingstarted project, on Heroku. Fore more info, see:
3https://github.com/heroku/heroku-django-template
4
5For more information on this file, see
6https://docs.djangoproject.com/en/1.8/topics/settings/
7
8For the full list of settings and their values, see
9https://docs.djangoproject.com/en/1.8/ref/settings/
10"""
11
12import os
13import dj_database_url
14
15
16# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17BASE_DIR = os.path.dirname(os.path.dirname(__file__))
18PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
19
20
21# Quick-start development settings - unsuitable for production
22# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
23
24# SECURITY WARNING: change this before deploying to production!
25SECRET_KEY = 'i+acxn5(akgsn!sr4axc41ml*f=s'
26
27# SECURITY WARNING: don't run with debug turned on in production!
28DEBUG = True
29
30ALLOWED_HOSTS = ['0.0.0.0',".herokuapp.com", 'www.thecolornet.com','thecolornet.com', 'newsletter-example.herokuapp.com' ,'localhost', '127.0.0.1']
31
32EMAIL_HOST = 'smtp.gmail.com'
33EMAIL_HOST_USER = 'iasasddsd@gmail.com'
34EMAIL_HOST_PASSWORD = 'unbdsds12'
35EMAIL_PORT = 587
36EMAIL_USE_TLS = True
37
38# Application definition
39
40INSTALLED_APPS = (
41 'django.contrib.admin',
42 'django.contrib.sites',
43 'registration',
44 'django.contrib.auth',
45 'django.contrib.contenttypes',
46 'django.contrib.sessions',
47 'django.contrib.messages',
48 'django.contrib.staticfiles',
49 # third party apps
50 'crispy_forms',
51 # my apps
52 'newsletter',
53 'blog',
54
55)
56
57MIDDLEWARE_CLASSES = (
58 'django.contrib.sessions.middleware.SessionMiddleware',
59 'django.middleware.common.CommonMiddleware',
60 'django.middleware.csrf.CsrfViewMiddleware',
61 'django.contrib.auth.middleware.AuthenticationMiddleware',
62 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
63 'django.contrib.messages.middleware.MessageMiddleware',
64 'django.middleware.clickjacking.XFrameOptionsMiddleware',
65 'django.middleware.security.SecurityMiddleware',
66)
67
68ROOT_URLCONF = 'gettingstarted.urls'
69
70TEMPLATES = [
71 {
72 'BACKEND': 'django.template.backends.django.DjangoTemplates',
73 'DIRS': [os.path.join(BASE_DIR, "templates")],
74 'APP_DIRS': True,
75 'OPTIONS': {
76 'debug': True,
77 'context_processors': [
78 'django.template.context_processors.debug',
79 'django.template.context_processors.request',
80 'django.contrib.auth.context_processors.auth',
81 'django.contrib.messages.context_processors.messages',
82 ],
83 },
84 },
85]
86
87WSGI_APPLICATION = 'gettingstarted.wsgi.application'
88
89
90# Database
91# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
92
93DATABASES = {
94 'default': {
95 'ENGINE': 'django.db.backends.postgresql_psycopg2',
96 'NAME': 'postgresqfdf715',
97 'USER': 'lamfdqlgw',
98 'PASSWORD': 'bfdfdv42',
99 'HOST': 'ec2-176-34-127-73.eu-west-1.compute.amazonaws.com',
100 'PORT': '5432',
101 }
102}
103
104
105
106# Password validation
107# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
108
109AUTH_PASSWORD_VALIDATORS = [
110 {
111 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
112 },
113 {
114 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
115 },
116 {
117 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
118 },
119 {
120 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
121 },
122]
123
124# Internationalization
125# https://docs.djangoproject.com/en/1.8/topics/i18n/
126
127LANGUAGE_CODE = 'en-us'
128TIME_ZONE = 'UTC'
129USE_I18N = True
130USE_L10N = True
131USE_TZ = True
132
133
134# Update database configuration with $DATABASE_URL.
135db_from_env = dj_database_url.config(conn_max_age=500)
136DATABASES['default'].update(db_from_env)
137
138# Honor the 'X-Forwarded-Proto' header for request.is_secure()
139SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
140
141
142
143
144# Static files (CSS, JavaScript, Images)
145# https://docs.djangoproject.com/en/1.8/howto/static-files/
146
147STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
148STATIC_URL = '/static/'
149
150# Extra places for collectstatic to find static files.
151STATICFILES_DIRS = (
152 os.path.join(PROJECT_ROOT, 'static'),
153)
154
155# Simplified static file serving.
156# https://warehouse.python.org/project/whitenoise/
157if not DEBUG:
158 STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
159
160
161
162# django registration redux settings
163ACCOUNT_ACTIVATION_DAYS = 7
164REGISTRATION_AUTO_LOGIN = True
165
166SITE_ID = 1
167LOGIN_REDIRECT_URL = '/'
168
169# crispy forms tag settings
170CRISPY_TEMPLATE_PACK = "bootstrap3"
171
172MEDIA_ROOT = os.path.join(BASE_DIR, "media")
173MEDIA_URL = "/media/"
174
175LOGGING = {
176 'version': 1,
177 'disable_existing_loggers': False,
178 'handlers': {
179 'console': {
180 'class': 'logging.StreamHandler',
181 },
182 },
183 'loggers': {
184 'django': {
185 'handlers': ['console'],
186 'level': os.getenv('DJANGO_LOG_LEVEL', 'ERROR'),
187 },
188 },
189}