Ivy-Backend/ivy/config/settings.py

172 lines
4.6 KiB
Python
Raw Normal View History

2023-02-27 23:59:14 +08:00
"""
Django settings for ivy project.
Generated by 'django-admin startproject' using Django 4.1.7.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
from dotenv import load_dotenv
import os
load_dotenv()
2023-02-27 23:59:14 +08:00
# 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/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY')
2023-02-27 23:59:14 +08:00
# SECURITY WARNING: don't run with debug turned on in production!
2023-03-29 14:09:24 +08:00
DEBUG = True
2023-02-27 23:59:14 +08:00
2023-03-29 14:09:24 +08:00
ALLOWED_HOSTS = ['lemeow125.github.io',
'keannu125.pythonanywhere.com', '127.0.0.1']
2023-02-27 23:59:14 +08:00
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
2023-02-28 22:16:45 +08:00
'rest_framework.authtoken',
'djoser',
2023-02-28 22:40:37 +08:00
'corsheaders',
2023-03-05 21:56:48 +08:00
'products',
'simple_history',
2023-02-27 23:59:14 +08:00
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
2023-03-11 00:14:04 +08:00
"whitenoise.middleware.WhiteNoiseMiddleware",
2023-02-27 23:59:14 +08:00
'django.contrib.sessions.middleware.SessionMiddleware',
2023-02-28 22:40:37 +08:00
"corsheaders.middleware.CorsMiddleware",
2023-02-27 23:59:14 +08:00
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'simple_history.middleware.HistoryRequestMiddleware',
2023-02-27 23:59:14 +08:00
]
ROOT_URLCONF = 'config.urls'
2023-02-27 23:59:14 +08:00
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 = 'config.wsgi.application'
2023-02-27 23:59:14 +08:00
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.1/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/4.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
2023-03-05 21:56:48 +08:00
TIME_ZONE = 'Asia/Manila'
2023-02-27 23:59:14 +08:00
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = 'static/'
2023-03-11 00:08:35 +08:00
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
2023-02-27 23:59:14 +08:00
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
2023-02-28 22:16:45 +08:00
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
)
}
DOMAIN = 'lemeow125.github.io/Ivy/#'
SITE_NAME = 'lemeow125.github.io/Ivy/#'
2023-03-05 22:05:18 +08:00
2023-02-28 22:16:45 +08:00
DJOSER = {
'SEND_ACTIVATION_EMAIL': True,
'SEND_CONFIRMATION_EMAIL': True,
'ACTIVATION_URL': 'activation/{uid}/{token}',
2023-03-07 20:39:16 +08:00
'PERMISSIONS': {
'user': ['rest_framework.permissions.AllowAny'],
'user_list': ['rest_framework.permissions.AllowAny'],
},
2023-02-28 22:16:45 +08:00
}
# Mailtrap SMTP Testing
# EMAIL_HOST = 'sandbox.smtp.mailtrap.io'
# EMAIL_HOST_USER = '54ff6949e39105'
# EMAIL_HOST_PASSWORD = 'c59d3eaa05f98d'
# EMAIL_PORT = '2525'
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
2023-02-28 22:40:37 +08:00
2023-03-10 23:11:07 +08:00
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_CREDENTIALS = True