-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5d136e
commit f0e9788
Showing
1 changed file
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
import dj_database_url | ||
from pathlib import Path | ||
import os | ||
from decouple import config, Csv | ||
import cloudinary | ||
import cloudinary.uploader | ||
import cloudinary.api | ||
import django_heroku | ||
|
||
|
||
cloudinary.config( | ||
cloud_name=config("CLOUD_NAME"), | ||
api_key=config('API_KEY'), | ||
api_secret=config("API_SECRET") | ||
|
||
) | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = config('SECRET_KEY') | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = config('DEBUG', default=False, cast=bool) | ||
|
||
# ALLOWED_HOSTS = ['jango-galleria.herokuapp.com', 'localhost'] | ||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'livereload', | ||
'django.contrib.staticfiles', | ||
'django.contrib.messages', | ||
'cloudinary', | ||
'accounts.apps.AccountsConfig', | ||
'businesses.apps.BusinessesConfig', | ||
'neighborhoods.apps.NeighborhoodsConfig', | ||
'posts.apps.PostsConfig', | ||
"rest_framework", | ||
'rest_framework_swagger', | ||
'rest_framework.authtoken' | ||
|
||
|
||
] | ||
|
||
MIDDLEWARE = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'whitenoise.middleware.WhiteNoiseMiddleware', | ||
'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', | ||
'livereload.middleware.LiveReloadScript', | ||
] | ||
|
||
REST_FRAMEWORK = { | ||
'DEFAULT_AUTHENTICATION_CLASSES': ( | ||
'rest_framework.authentication.TokenAuthentication', | ||
'rest_framework.authentication.SessionAuthentication', | ||
), | ||
'DEFAULT_PERMISSION_CLASSES': ( | ||
'rest_framework.permissions.IsAuthenticated', | ||
) | ||
} | ||
|
||
|
||
ROOT_URLCONF = 'community.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'community.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases | ||
|
||
# development | ||
if config('MODE') == "dev": | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.postgresql', | ||
'NAME': config('DB_NAME'), | ||
'USER': config('DB_USER'), | ||
'PASSWORD': config('DB_PASSWORD'), | ||
} | ||
} | ||
# production | ||
else: | ||
DATABASES = { | ||
'default': dj_database_url.config( | ||
default=config('DATABASE_URL') | ||
) | ||
} | ||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/3.2/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', | ||
}, | ||
] | ||
|
||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/3.2/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'Africa/Nairobi' | ||
|
||
USE_I18N = True | ||
|
||
USE_L10N = True | ||
|
||
USE_TZ = True | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/3.2/howto/static-files/ | ||
|
||
# Default primary key field type | ||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field | ||
|
||
LOGIN_REDIRECT_URL = '/' | ||
LOGOUT_REDIRECT_URL = '/' | ||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' | ||
|
||
# Heroku: Update database configuration from $DATABASE_URL. | ||
db_from_env = dj_database_url.config(conn_max_age=500) | ||
DATABASES['default'].update(db_from_env) | ||
django_heroku.settings(locals()) | ||
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv()) |