/config/settings/base.py
Python | 233 lines | 140 code | 26 blank | 67 comment | 0 complexity | 05f40486c3b49c04fbc5d4424d21c522 MD5 | raw file
- """
- Base settings to build other settings files upon.
- """
- import environ
- import os
- ROOT_DIR = environ.Path(__file__) - 3 # (bootcamp/config/settings/base.py - 3 = bootcamp/)
- APPS_DIR = ROOT_DIR.path('bootcamp')
- env = environ.Env()
- env.read_env(str(ROOT_DIR.path('.env')))
- # SECRET_KEY = get_env_variable('SECRET_KEY')
- # def get_env_variable(var_name):
- # try:
- # return os.environ[var_name]
- # except KeyError:
- # error_msg = "Set the %s environment variable" % var_name
- # raise ImproperlyConfigured(error_msg)
- # SECRET_KEY = get_env_variable('SECRET_KEY')
- SECRET_KEY = '!x!m)x(5y*5toypbxb4--h^=rx)o764uplz_@4ec3zjkd8ij2z'
- DATABASE_URL ='sqlite:////path/to/root/folder/random_name.sqlite3'
- # GENERAL
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#debug
- DEBUG = env.bool('DJANGO_DEBUG', True)
- # Local time zone. Choices are
- # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
- # though not all of them may be available with every OS.
- # In Windows, this must be set to your system time zone.
- TIME_ZONE = 'UTC'
- # https://docs.djangoproject.com/en/dev/ref/settings/#language-code
- LANGUAGE_CODE = 'en-us'
- # https://docs.djangoproject.com/en/dev/ref/settings/#site-id
- SITE_ID = 1
- # https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
- USE_I18N = True
- # https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
- USE_L10N = True
- # https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
- USE_TZ = True
- LANGUAGES = (
- ('en', 'English'),
- ('pt-br', 'Portuguese'),
- ('es', 'Spanish'),
- ('zh-cn', 'Chinese'),
- )
- LOCALE_PATHS = (str(APPS_DIR.path('locale')), )
- # DATABASES
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#databases
- DATABASES = {
- 'default': env.db('DATABASE_URL'),
- }
- DATABASES['default']['ATOMIC_REQUESTS'] = True
- # URLS
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
- ROOT_URLCONF = 'config.urls'
- # https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
- WSGI_APPLICATION = 'config.wsgi.application'
- # APPS
- # ------------------------------------------------------------------------------
- DJANGO_APPS = [
- 'jet.dashboard',
- 'jet',
-
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.sites',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'django.contrib.humanize',
- ]
- THIRD_PARTY_APPS = [
- 'taggit',
- 'channels',
- ]
- LOCAL_APPS = [
- 'bootcamp.activities',
- 'bootcamp.articles',
- 'bootcamp.authentication',
- 'bootcamp.core',
- 'bootcamp.feeds',
- 'bootcamp.messenger',
- 'bootcamp.questions',
- 'bootcamp.search',
-
- 'tpo.apps.TpoConfig',
-
- ]
- # https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
- INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
- # https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
- LOGIN_REDIRECT_URL = 'feeds'
- # https://docs.djangoproject.com/en/dev/ref/settings/#login-url
- LOGIN_URL = '/'
- # PASSWORDS
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
- PASSWORD_HASHERS = [
- # https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
- 'django.contrib.auth.hashers.Argon2PasswordHasher',
- 'django.contrib.auth.hashers.PBKDF2PasswordHasher',
- 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
- 'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
- 'django.contrib.auth.hashers.BCryptPasswordHasher',
- ]
- # https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
- AUTH_PASSWORD_VALIDATORS = [
- {
- 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
- },
- ]
- # MIDDLEWARE
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#middleware
- MIDDLEWARE = [
- 'django.middleware.security.SecurityMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'django.middleware.locale.LocaleMiddleware',
- ]
- # STATIC
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#static-root
- STATIC_ROOT = str(ROOT_DIR('staticfiles'))
- # https://docs.djangoproject.com/en/dev/ref/settings/#static-url
- STATIC_URL = '/static/'
- # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
- STATICFILES_DIRS = [
- str(APPS_DIR.path('static')),
- ]
- # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
- STATICFILES_FINDERS = [
- 'django.contrib.staticfiles.finders.FileSystemFinder',
- 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
- ]
- # MEDIA
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#media-root
- MEDIA_ROOT = str(APPS_DIR('media'))
- # https://docs.djangoproject.com/en/dev/ref/settings/#media-url
- MEDIA_URL = '/media/'
- # TEMPLATES
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#templates
- TEMPLATES = [
- {
- # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
- 'BACKEND': 'django.template.backends.django.DjangoTemplates',
- # https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
- 'DIRS': [
- str(APPS_DIR.path('templates')),
- ],
- 'OPTIONS': {
- # https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
- 'debug': DEBUG,
- # https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
- # https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
- 'loaders': [
- 'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
- ],
- # https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
- 'context_processors': [
- 'django.template.context_processors.debug',
- 'django.template.context_processors.request',
- 'django.contrib.auth.context_processors.auth',
- 'django.template.context_processors.i18n',
- 'django.template.context_processors.media',
- 'django.template.context_processors.static',
- 'django.template.context_processors.tz',
- 'django.contrib.messages.context_processors.messages',
- ],
- },
- },
- ]
- # EMAIL
- # ------------------------------------------------------------------------------
- # https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
- EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
- ALLOWED_SIGNUP_DOMAINS = ['*']
- FILE_UPLOAD_TEMP_DIR = '/tmp/'
- FILE_UPLOAD_PERMISSIONS = 0o644
- TAGGIT_CASE_INSENSITIVE = True
- EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
- EMAIL_USE_TLS = True
- EMAIL_HOST = 'smtp.gmail.com'
- EMAIL_PORT = 587
- EMAIL_HOST_USER = 'abc@gmail.com'
- EMAIL_HOST_PASSWORD = 'password'
- # EMAIL_BACKEND = "sgbackend.SendGridBackend"
- # SENDGRID_API_KEY = "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"
- NOTIFIER_BACKENDS = (
- 'notifier.backends.EmailBackend',
- 'path.to.custom.backend.CustomBackend',
- )