· 8 years ago · Jul 06, 2017, 06:28 AM
1import os
2import admin_app
3from django.utils import timezone
4import django_mongodb_engine.base
5from mongoengine import connect
6connect('pom')
7
8
9BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10
11# SECURITY WARNING: keep the secret key used in production secret!
12SECRET_KEY = 'uj8$6(ol=!w)b3-luqzb=#6(j19gkbrnp2asq6=xt%5*s2ylz('
13
14DEBUG = True
15
16ALLOWED_HOSTS = []
17
18SPATIALITE_LIBRARY_PATH = 'mod_spatialite'
19# Application definition
20
21INSTALLED_APPS = (
22 'django.contrib.admin',
23 'django.contrib.auth',
24 'django.contrib.contenttypes',
25 'django.contrib.sessions',
26 'django.contrib.messages',
27 'django.contrib.staticfiles',
28 'rest_framework',
29 'djangotoolbox',
30 'admin_app',
31 'celery',
32)
33
34MIDDLEWARE_CLASSES = (
35 'django.contrib.sessions.middleware.SessionMiddleware',
36 'django.middleware.common.CommonMiddleware',
37 'django.middleware.csrf.CsrfViewMiddleware',
38 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
39 'django.contrib.auth.middleware.AuthenticationMiddleware',
40 'django.contrib.messages.middleware.MessageMiddleware',
41 'django.middleware.clickjacking.XFrameOptionsMiddleware',
42 #'django.middleware.security.SecurityMiddleware',
43 'djangoflash.middleware.FlashMiddleware',
44 'django.middleware.cache.CacheMiddleware',
45)
46
47
48ROOT_URLCONF = 'admin_python.urls'
49
50TEMPLATES = [
51 {
52 'BACKEND': 'django.template.backends.django.DjangoTemplates',
53 'DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'media')],
54 'APP_DIRS': True,
55 'OPTIONS': {
56 'context_processors': [
57 'django.template.context_processors.debug',
58 'django.template.context_processors.request',
59 'django.contrib.auth.context_processors.auth',
60 'django.contrib.messages.context_processors.messages',
61 'admin_app.context_processors.init_menu',
62 'admin_app.context_processors.server_urls',
63 'djangoflash.context_processors.flash',
64 ],
65 },
66 },
67]
68
69
70STATICFILES_FINDERS = (
71 'django.contrib.staticfiles.finders.FileSystemFinder',
72 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
73)
74STATIC_ROOT = os.path.join(BASE_DIR, "static/")
75MEDIA_URL = '/media/'
76HOST_URL='http://127.0.0.1:8001/media/'
77MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
78WSGI_APPLICATION = 'admin_python.wsgi.application'
79STATIC_URL = '/static/'
80SERVER_URL = 'http://localhost:8001/'
81WEBAPP_URL = 'http://localhost/webapp_angular/'
82USERAPI_URL = 'http://localhost:8000/'
83HOST_URL_NEW='http://localhost:8001/media/'
84
85
86# Database
87# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
88"""DATABASES = {'default': {
89'ENGINE': 'django.db.backends.mysql',
90'NAME': 'admin_db',
91'USER': 'root',
92'PASSWORD': 'root',
93'HOST': 'localhost',
94}}"""
95
96DATABASES = {
97 'default' : {
98 'ENGINE': 'django_mongodb_engine',
99 'NAME' : 'pom'
100 }
101}
102
103LANGUAGE_CODE = 'en-us'
104
105TIME_ZONE = 'Asia/Kolkata'
106
107USE_I18N = True
108
109USE_L10N = True
110
111USE_TZ = False
112
113
114
115REST_FRAMEWORK = {
116 # other settings...
117
118 'DEFAULT_AUTHENTICATION_CLASSES': [],
119 'DEFAULT_PERMISSION_CLASSES': [],
120}
121LOGIN_URL = '/auth/login/'
122LOGIN_REDIRECT_URL = '/'
123
124AUTHENTICATION_BACKENDS = (
125 'admin_app.backend.AuthBackend',
126 'mongoengine.django.auth.MongoEngineBackend'
127 'django.contrib.auth.backends.ModelBackend',
128)
129
130AUTH_USER_MODEL = 'admin_app.TblAdmin'
131
132EMAIL_HOST = 'email-smtp.us-east-1.amazonaws.com'
133EMAIL_PORT = 587
134EMAIL_HOST_USER = 'AKIAJB6VACOVZANVTC5A'
135EMAIL_HOST_PASSWORD = 'Atu9qbV+X5aiwIlQzVAOVjU/AxkxMDV3X0l0FLWweSn9'
136EMAIL_USE_TLS = True
137DEFAULT_FROM_EMAIL = 'support@doctorinsta.com'
138
139#LOGGING SETTING
140LOGGING = {
141 'version': 1,
142 'disable_existing_loggers': False,
143 'formatters': {
144 'verbose': {
145 'format' : "[%(asctime)s] %(levelname)s [%(filename)s:%(funcName)s:%(lineno)s] %(message)s",
146 'datefmt' : "%d/%b/%Y %H:%M:%S"
147 },
148 'simple': {
149 'format': '%(levelname)s %(message)s'
150 },
151 },
152 'filters': {
153 'require_debug_false': {
154 '()': 'django.utils.log.RequireDebugFalse'
155 }
156 },
157 'handlers': {
158 'mail_admins': {
159 'level': 'ERROR',
160 'filters': ['require_debug_false'],
161 'class': 'django.utils.log.AdminEmailHandler'
162 },
163 'applogfile': {
164 'level':'DEBUG',
165 'class':'logging.FileHandler',
166 'filename': os.path.join(BASE_DIR, 'drinsta.log'),
167 'formatter': 'verbose'
168 },
169
170 },
171 'loggers': {
172 'django.request': {
173 'level': 'ERROR',
174 'propagate': True,
175 'handlers': ['applogfile',],
176 },
177 'drinsta': {
178 'handlers': ['applogfile',],
179 'level': 'DEBUG',
180 },
181 }
182}
183
184#We can use the following command to see the keys:
185# python -m memcached_stats 127.0.0.1 11211
186CACHES = {
187 'default': {
188 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
189 'LOCATION': '127.0.0.1:11211',
190 'TIMEOUT' : 300 #Default
191 }
192}
193CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
194
195SESSION_ENGINE= 'django.contrib.sessions.backends.cache'
196
197'''
198RabbitMQ configurations begins
199'''
200#OLD FORMAT:
201# BROKER_HOST = "127.0.0.1"
202# BROKER_PORT = 5672 # default RabbitMQ listening port
203# BROKER_USER = "admin"
204# BROKER_PASSWORD = "admin"
205# BROKER_VHOST = "admin" #Virtual hosts provide a way to segregate applications using the same RabbitMQ instance. Different users can have different access privileges to different vhost and queues and exchanges can be created so they only exists in one vhost.
206
207#NEW FORMAT:
208BROKER_URL = 'amqp://admin:admin@localhost:5672/admin'
209'''
210RabbitMQ configurations ends
211'''
212'''
213Celery configurations begins
214'''
215#CELERY_BACKEND = "amqp" # telling Celery to report the results back to RabbitMQ
216#'amqp' means Advanced Message Queuing Protocol
217# CELERY_RESULT_DBURI = ""
218CELERY_TIMEZONE = "Asia/Kolkata"
219#CELERY_RESULT_BACKEND='djcelery.backends.cache:CacheBackend'
220CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend'
221
222CELERY_IMPORTS = ("tasks", )
223CELERY_RESULT_PERSISTENT = True #If set to True, result messages will be persistent. This means the messages will not be lost after a broker restart. The default is for the results to be transient.
224CELERY_TASK_RESULT_EXPIRES = None