example-of-crud-in-django-w.../project/settings.py

129 lines
3.2 KiB
Python
Raw Normal View History

2021-07-05 15:56:53 +02:00
from pathlib import Path
2021-07-15 15:49:47 +02:00
import dj_database_url
2021-07-14 17:12:41 +02:00
import django_heroku
2021-07-15 15:49:47 +02:00
from os import environ
2021-07-05 15:56:53 +02: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/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
2021-07-15 15:49:47 +02:00
SECRET_KEY = "mysecret"
2021-07-05 15:56:53 +02:00
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
2021-07-13 18:30:31 +02:00
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
2021-07-14 16:46:34 +02:00
"rest_framework",
"app.library",
"django_extensions",
2021-07-05 15:56:53 +02:00
]
MIDDLEWARE = [
2021-07-13 18:30:31 +02:00
"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",
2021-07-05 15:56:53 +02:00
]
2021-07-14 17:17:52 +02:00
ROOT_URLCONF = "project.urls"
2021-07-05 15:56:53 +02:00
TEMPLATES = [
{
2021-07-13 18:30:31 +02:00
"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",
2021-07-05 15:56:53 +02:00
],
},
},
]
2021-07-14 17:17:52 +02:00
WSGI_APPLICATION = "project.wsgi.application"
2021-07-05 15:56:53 +02:00
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
2021-07-15 15:49:47 +02:00
if environ.get("DATABASE_URL"):
DATABASES = {}
DATABASES['default'] = dj_database_url.config(conn_max_age=600)
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "database.sqlite",
}
2021-07-05 15:56:53 +02:00
}
2021-07-15 15:49:47 +02:00
2021-07-05 15:56:53 +02:00
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
2021-07-13 18:30:31 +02:00
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
2021-07-05 15:56:53 +02:00
},
{
2021-07-13 18:30:31 +02:00
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
2021-07-05 15:56:53 +02:00
},
{
2021-07-13 18:30:31 +02:00
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
2021-07-05 15:56:53 +02:00
},
{
2021-07-13 18:30:31 +02:00
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
2021-07-05 15:56:53 +02:00
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
2021-07-13 18:30:31 +02:00
LANGUAGE_CODE = "en-us"
2021-07-05 15:56:53 +02:00
2021-07-13 18:30:31 +02:00
TIME_ZONE = "UTC"
2021-07-05 15:56:53 +02:00
2021-07-14 16:19:03 +02:00
USE_I18N = False
2021-07-05 15:56:53 +02:00
2021-07-14 16:19:03 +02:00
USE_L10N = False
2021-07-05 15:56:53 +02:00
2021-07-14 16:19:03 +02:00
USE_TZ = False
2021-07-05 15:56:53 +02:00
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
2021-07-13 18:30:31 +02:00
STATIC_URL = "/static/"
2021-07-14 16:58:09 +02:00
STATIC_ROOT = "static"
2021-07-05 15:56:53 +02:00
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
2021-07-13 18:30:31 +02:00
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
2021-07-14 17:12:41 +02:00
# Activate Django-Heroku.
django_heroku.settings(locals())