PageRenderTime 52ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/config/settings/base.py

https://bitbucket.org/mansi1007/ras
Python | 233 lines | 140 code | 26 blank | 67 comment | 0 complexity | 05f40486c3b49c04fbc5d4424d21c522 MD5 | raw file
  1. """
  2. Base settings to build other settings files upon.
  3. """
  4. import environ
  5. import os
  6. ROOT_DIR = environ.Path(__file__) - 3 # (bootcamp/config/settings/base.py - 3 = bootcamp/)
  7. APPS_DIR = ROOT_DIR.path('bootcamp')
  8. env = environ.Env()
  9. env.read_env(str(ROOT_DIR.path('.env')))
  10. # SECRET_KEY = get_env_variable('SECRET_KEY')
  11. # def get_env_variable(var_name):
  12. # try:
  13. # return os.environ[var_name]
  14. # except KeyError:
  15. # error_msg = "Set the %s environment variable" % var_name
  16. # raise ImproperlyConfigured(error_msg)
  17. # SECRET_KEY = get_env_variable('SECRET_KEY')
  18. SECRET_KEY = '!x!m)x(5y*5toypbxb4--h^=rx)o764uplz_@4ec3zjkd8ij2z'
  19. DATABASE_URL ='sqlite:////path/to/root/folder/random_name.sqlite3'
  20. # GENERAL
  21. # ------------------------------------------------------------------------------
  22. # https://docs.djangoproject.com/en/dev/ref/settings/#debug
  23. DEBUG = env.bool('DJANGO_DEBUG', True)
  24. # Local time zone. Choices are
  25. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  26. # though not all of them may be available with every OS.
  27. # In Windows, this must be set to your system time zone.
  28. TIME_ZONE = 'UTC'
  29. # https://docs.djangoproject.com/en/dev/ref/settings/#language-code
  30. LANGUAGE_CODE = 'en-us'
  31. # https://docs.djangoproject.com/en/dev/ref/settings/#site-id
  32. SITE_ID = 1
  33. # https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
  34. USE_I18N = True
  35. # https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
  36. USE_L10N = True
  37. # https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
  38. USE_TZ = True
  39. LANGUAGES = (
  40. ('en', 'English'),
  41. ('pt-br', 'Portuguese'),
  42. ('es', 'Spanish'),
  43. ('zh-cn', 'Chinese'),
  44. )
  45. LOCALE_PATHS = (str(APPS_DIR.path('locale')), )
  46. # DATABASES
  47. # ------------------------------------------------------------------------------
  48. # https://docs.djangoproject.com/en/dev/ref/settings/#databases
  49. DATABASES = {
  50. 'default': env.db('DATABASE_URL'),
  51. }
  52. DATABASES['default']['ATOMIC_REQUESTS'] = True
  53. # URLS
  54. # ------------------------------------------------------------------------------
  55. # https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
  56. ROOT_URLCONF = 'config.urls'
  57. # https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
  58. WSGI_APPLICATION = 'config.wsgi.application'
  59. # APPS
  60. # ------------------------------------------------------------------------------
  61. DJANGO_APPS = [
  62. 'jet.dashboard',
  63. 'jet',
  64. 'django.contrib.admin',
  65. 'django.contrib.auth',
  66. 'django.contrib.contenttypes',
  67. 'django.contrib.sessions',
  68. 'django.contrib.sites',
  69. 'django.contrib.messages',
  70. 'django.contrib.staticfiles',
  71. 'django.contrib.humanize',
  72. ]
  73. THIRD_PARTY_APPS = [
  74. 'taggit',
  75. 'channels',
  76. ]
  77. LOCAL_APPS = [
  78. 'bootcamp.activities',
  79. 'bootcamp.articles',
  80. 'bootcamp.authentication',
  81. 'bootcamp.core',
  82. 'bootcamp.feeds',
  83. 'bootcamp.messenger',
  84. 'bootcamp.questions',
  85. 'bootcamp.search',
  86. 'tpo.apps.TpoConfig',
  87. ]
  88. # https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
  89. INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
  90. # https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
  91. LOGIN_REDIRECT_URL = 'feeds'
  92. # https://docs.djangoproject.com/en/dev/ref/settings/#login-url
  93. LOGIN_URL = '/'
  94. # PASSWORDS
  95. # ------------------------------------------------------------------------------
  96. # https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
  97. PASSWORD_HASHERS = [
  98. # https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
  99. 'django.contrib.auth.hashers.Argon2PasswordHasher',
  100. 'django.contrib.auth.hashers.PBKDF2PasswordHasher',
  101. 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
  102. 'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
  103. 'django.contrib.auth.hashers.BCryptPasswordHasher',
  104. ]
  105. # https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
  106. AUTH_PASSWORD_VALIDATORS = [
  107. {
  108. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  109. },
  110. {
  111. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  112. },
  113. {
  114. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  115. },
  116. {
  117. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  118. },
  119. ]
  120. # MIDDLEWARE
  121. # ------------------------------------------------------------------------------
  122. # https://docs.djangoproject.com/en/dev/ref/settings/#middleware
  123. MIDDLEWARE = [
  124. 'django.middleware.security.SecurityMiddleware',
  125. 'django.contrib.sessions.middleware.SessionMiddleware',
  126. 'django.middleware.common.CommonMiddleware',
  127. 'django.middleware.csrf.CsrfViewMiddleware',
  128. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  129. 'django.contrib.messages.middleware.MessageMiddleware',
  130. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  131. 'django.middleware.locale.LocaleMiddleware',
  132. ]
  133. # STATIC
  134. # ------------------------------------------------------------------------------
  135. # https://docs.djangoproject.com/en/dev/ref/settings/#static-root
  136. STATIC_ROOT = str(ROOT_DIR('staticfiles'))
  137. # https://docs.djangoproject.com/en/dev/ref/settings/#static-url
  138. STATIC_URL = '/static/'
  139. # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
  140. STATICFILES_DIRS = [
  141. str(APPS_DIR.path('static')),
  142. ]
  143. # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
  144. STATICFILES_FINDERS = [
  145. 'django.contrib.staticfiles.finders.FileSystemFinder',
  146. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  147. ]
  148. # MEDIA
  149. # ------------------------------------------------------------------------------
  150. # https://docs.djangoproject.com/en/dev/ref/settings/#media-root
  151. MEDIA_ROOT = str(APPS_DIR('media'))
  152. # https://docs.djangoproject.com/en/dev/ref/settings/#media-url
  153. MEDIA_URL = '/media/'
  154. # TEMPLATES
  155. # ------------------------------------------------------------------------------
  156. # https://docs.djangoproject.com/en/dev/ref/settings/#templates
  157. TEMPLATES = [
  158. {
  159. # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
  160. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  161. # https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
  162. 'DIRS': [
  163. str(APPS_DIR.path('templates')),
  164. ],
  165. 'OPTIONS': {
  166. # https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
  167. 'debug': DEBUG,
  168. # https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
  169. # https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
  170. 'loaders': [
  171. 'django.template.loaders.filesystem.Loader',
  172. 'django.template.loaders.app_directories.Loader',
  173. ],
  174. # https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
  175. 'context_processors': [
  176. 'django.template.context_processors.debug',
  177. 'django.template.context_processors.request',
  178. 'django.contrib.auth.context_processors.auth',
  179. 'django.template.context_processors.i18n',
  180. 'django.template.context_processors.media',
  181. 'django.template.context_processors.static',
  182. 'django.template.context_processors.tz',
  183. 'django.contrib.messages.context_processors.messages',
  184. ],
  185. },
  186. },
  187. ]
  188. # EMAIL
  189. # ------------------------------------------------------------------------------
  190. # https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
  191. EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
  192. ALLOWED_SIGNUP_DOMAINS = ['*']
  193. FILE_UPLOAD_TEMP_DIR = '/tmp/'
  194. FILE_UPLOAD_PERMISSIONS = 0o644
  195. TAGGIT_CASE_INSENSITIVE = True
  196. EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  197. EMAIL_USE_TLS = True
  198. EMAIL_HOST = 'smtp.gmail.com'
  199. EMAIL_PORT = 587
  200. EMAIL_HOST_USER = 'abc@gmail.com'
  201. EMAIL_HOST_PASSWORD = 'password'
  202. # EMAIL_BACKEND = "sgbackend.SendGridBackend"
  203. # SENDGRID_API_KEY = "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"
  204. NOTIFIER_BACKENDS = (
  205. 'notifier.backends.EmailBackend',
  206. 'path.to.custom.backend.CustomBackend',
  207. )