· 8 years ago · Dec 27, 2017, 06:10 PM
1import os
2
3
4# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
5BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
6
7
8# SECURITY WARNING: keep the secret key used in production secret!
9SECRET_KEY = '2z9y'
10# Simplified static file serving.
11# https://warehouse.python.org/project/whitenoise/
12STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
13
14
15ALLOWED_HOSTS = ['127.0.0.1', 'localhost','https://hackingonlineeducation.herokuapp.com']
16
17
18# Application definition
19
20INSTALLED_APPS = [
21 'django.contrib.admin',
22 'django.contrib.auth',
23 'django.contrib.contenttypes',
24 'django.contrib.sessions',
25 'django.contrib.messages',
26 'django.contrib.staticfiles',
27 #third party apps
28 'star_ratings',
29 'crispy_forms',
30 #my_apps
31 'newsletter',
32]
33
34MIDDLEWARE = [
35 'django.middleware.security.SecurityMiddleware',
36 'whitenoise.middleware.WhiteNoiseMiddleware',
37 'django.contrib.sessions.middleware.SessionMiddleware',
38 'django.middleware.common.CommonMiddleware',
39 'django.middleware.csrf.CsrfViewMiddleware',
40 'django.contrib.auth.middleware.AuthenticationMiddleware',
41 'django.contrib.messages.middleware.MessageMiddleware',
42 'django.middleware.clickjacking.XFrameOptionsMiddleware',
43]
44
45ROOT_URLCONF = 'Books.urls'
46
47TEMPLATES = [
48 {
49 'BACKEND': 'django.template.backends.django.DjangoTemplates',
50 'DIRS': [os.path.join(BASE_DIR,'templates')],
51 'APP_DIRS': True,
52 'OPTIONS': {
53 'context_processors': [
54 'django.template.context_processors.debug',
55 'django.template.context_processors.request',
56 'django.contrib.auth.context_processors.auth',
57 'django.contrib.messages.context_processors.messages',
58 ],
59 },
60 },
61]
62
63WSGI_APPLICATION = 'Books.wsgi.application'
64
65
66# Database
67# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
68
69DATABASES = {
70 'default': {
71 'ENGINE': 'django.db.backends.sqlite3',
72 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
73 }
74}
75
76
77# Password validation
78# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
79
80AUTH_PASSWORD_VALIDATORS = [
81 {
82 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
83 },
84 {
85 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
86 },
87 {
88 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
89 },
90 {
91 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
92 },
93]
94
95
96# Internationalization
97# https://docs.djangoproject.com/en/1.11/topics/i18n/
98
99LANGUAGE_CODE = 'en-us'
100
101TIME_ZONE = 'UTC'
102
103USE_I18N = True
104
105USE_L10N = True
106
107USE_TZ = True
108
109
110# Static files (CSS, JavaScript, Images)
111# https://docs.djangoproject.com/en/1.11/howto/static-files/
112
113STATIC_URL = '/static/'
114STATICFILES_DIRS = [
115 os.path.join(BASE_DIR, "static"),
116 os.path.join(BASE_DIR,"static","bootstrap")
117 # '/var/www/static/',
118]
119STATIC_ROOT=os.path.join(BASE_DIR,'static','static_root')
120
121MEDIA_URL='/media/'
122MEDIA_ROOT=os.path.join(BASE_DIR,'media','profile_images')
123
124#crispy_forms
125CRISPY_TEMPLATE_PACK = 'bootstrap3'
126
127LOGIN_REDIRECT_URL='profile'
128LOGOUT_REDIRECT_URL='home'
129
130from Books.settings.base import *
131
132DEBUG = True
133INSTALLED_APPS += (
134 'debug_toolbar', # and other apps for local development
135)
136
137MIDDLEWARE +=[
138'debug_toolbar.middleware.DebugToolbarMiddleware'
139]
140
141django.template.loaders.filesystem.Loader: /home/user/workspace/Books/Books/templates/home.html (Source does not exist)
142django.template.loaders.app_directories.Loader: /home/user/workspace/Books/venv/lib/python3.6/site-packages/django/contrib/admin/templates/home.html (Source does not exist)
143django.template.loaders.app_directories.Loader: /home/user/workspace/Books/venv/lib/python3.6/site-packages/django/contrib/auth/templates/home.html (Source does not exist)
144django.template.loaders.app_directories.Loader: /home/user/workspace/Books/venv/lib/python3.6/site-packages/star_ratings/templates/home.html (Source does not exist)
145django.template.loaders.app_directories.Loader: /home/user/workspace/Books/venv/lib/python3.6/site-packages/crispy_forms/templates/home.html (Source does not exist)
146django.template.loaders.app_directories.Loader: /home/user/workspace/Books/venv/lib/python3.6/site-packages/debug_toolbar/templates/home.html (Source does not exist)
147
148import os
149import sys
150
151if __name__ == "__main__":
152 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Books.settings.local")