· 9 years ago · Jul 11, 2016, 08:18 AM
1"""
2Django settings for hostel project.
3
4Generated by 'django-admin startproject' using Django 1.9.2.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/1.9/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/1.9/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.abspath(__file__))
17PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
18
19
20# Quick-start development settings - unsuitable for production
21# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
22
23# SECURITY WARNING: keep the secret key used in production secret!
24SECRET_KEY = '!9j0x7+yh!i*fgx=pkuxak=7@hj&)wc1i!9x=)+&v-5rs*gmjz'
25
26# SECURITY WARNING: don't run with debug turned on in production!
27DEBUG = True
28
29ALLOWED_HOSTS = ['kamsurf.herokuapp.com']
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 'storages',
41 'imagekit',
42 'bookings',
43 'guests',
44 'main',
45 'rooms',
46]
47
48MIDDLEWARE_CLASSES = [
49 'django.middleware.security.SecurityMiddleware',
50 'whitenoise.middleware.WhiteNoiseMiddleware',
51 'django.contrib.sessions.middleware.SessionMiddleware',
52 'django.middleware.common.CommonMiddleware',
53 'django.middleware.csrf.CsrfViewMiddleware',
54 'django.contrib.auth.middleware.AuthenticationMiddleware',
55 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
56 'django.contrib.messages.middleware.MessageMiddleware',
57 'django.middleware.clickjacking.XFrameOptionsMiddleware',
58]
59
60
61ROOT_URLCONF = 'hostel.urls'
62
63TEMPLATES = [
64 {
65 'BACKEND': 'django.template.backends.django.DjangoTemplates',
66 'DIRS': [os.path.join(PROJECT_ROOT, 'templates')],
67 'APP_DIRS': True,
68 'OPTIONS': {
69 'context_processors': [
70 'django.template.context_processors.debug',
71 'django.template.context_processors.request',
72 'django.contrib.auth.context_processors.auth',
73 'django.contrib.messages.context_processors.messages',
74 ],
75 },
76 },
77]
78
79WSGI_APPLICATION = 'hostel.wsgi.application'
80
81
82# Database
83# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
84
85SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
86
87DB_USER = os.environ.get('DB_USER')
88DB_PASSWORD = os.environ.get('DB_PASSWORD')
89
90DATABASES = {
91 'default': {
92 'ENGINE': 'django.db.backends.postgresql_psycopg2',
93 'NAME': 'd85it3amrfun3s',
94 'USER': 'DB_USER',
95 'PASSWORD': 'DB_PASSWORD',
96 'HOST': 'ec2-23-21-164-237.compute-1.amazonaws.com',
97 'PORT': '5432',
98 }
99}
100
101import dj_database_url
102
103DATABASES['default'] = dj_database_url.config()
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
125# Internationalization
126# https://docs.djangoproject.com/en/1.9/topics/i18n/
127
128LANGUAGE_CODE = 'en-us'
129
130TIME_ZONE = 'UTC'
131
132USE_I18N = True
133
134USE_L10N = True
135
136USE_TZ = True
137
138SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
139
140# Static files (CSS, JavaScript, Images)
141# https://docs.djangoproject.com/en/1.9/howto/static-files/
142
143# S3 Buket settings
144AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
145AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
146S3_STORAGE_BUCKET_NAME = os.environ.get('S3_STORAGE_BUCKET_NAME')
147S3_URL = 'https://%s.s3.amazonaws.com' % S3_STORAGE_BUCKET_NAME
148
149DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
150
151
152STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
153STATIC_URL = '/static/'
154STATICFILES_DIRS = (
155 os.path.join(PROJECT_ROOT, 'static'),
156 )
157
158# MEDIA_URL = '/media/'
159# MEDIA_ROOT = os.path.join(BASE_DIR, 'media_cdn')
160MEDIA_URL = S3_URL + '/media/'
161
162STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'