Coverage for project/base_settings.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Django settings for project project.
4Generated by 'django-admin startproject' using Django 3.0.4.
6For more information on this file, see
7https://docs.djangoproject.com/en/3.0/topics/settings/
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/3.0/ref/settings/
11"""
13import os
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16import sys
17from typing import Sequence
19BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
20MEDIA_ROOT = BASE_DIR
23# Quick-start development settings - unsuitable for production
24# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
26# SECURITY WARNING: don't run with debug turned on in production!
27DEBUG = False
29ALLOWED_HOSTS: Sequence[str] = []
32# Application definition
34INSTALLED_APPS = [
35 'django.contrib.admin',
36 'django.contrib.auth',
37 'django.contrib.contenttypes',
38 'django.contrib.sessions',
39 'django.contrib.messages',
40 'django.contrib.staticfiles',
41 'rest_framework',
42 'rest_framework.authtoken',
43 'jutil',
44]
46MIDDLEWARE = [
47 'django.middleware.security.SecurityMiddleware',
48 'django.contrib.sessions.middleware.SessionMiddleware',
49 'django.middleware.common.CommonMiddleware',
50 'django.middleware.csrf.CsrfViewMiddleware',
51 'django.contrib.auth.middleware.AuthenticationMiddleware',
52 'django.contrib.messages.middleware.MessageMiddleware',
53 'django.middleware.clickjacking.XFrameOptionsMiddleware',
54]
56ROOT_URLCONF = 'project.urls'
58TEMPLATES = [
59 {
60 'BACKEND': 'django.template.backends.django.DjangoTemplates',
61 'DIRS': [],
62 'APP_DIRS': True,
63 'OPTIONS': {
64 'context_processors': [
65 'django.template.context_processors.debug',
66 'django.template.context_processors.request',
67 'django.contrib.auth.context_processors.auth',
68 'django.contrib.messages.context_processors.messages',
69 ],
70 },
71 },
72]
74WSGI_APPLICATION = 'project.wsgi.application'
76# Logging
78LOGGING = {
79 'version': 1,
80 'disable_existing_loggers': False,
81 'filters': {
82 'ndebug': {
83 '()': 'django.utils.log.RequireDebugFalse',
84 },
85 },
86 'formatters': {
87 'verbose': {
88 'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
89 'datefmt' : "%Y-%m-%d %H:%M:%S"
90 },
91 'simple': {
92 'format': '%(levelname)s %(message)s'
93 },
94 },
95 'handlers': {
96 'file': {
97 'level': 'DEBUG',
98 'class': 'logging.FileHandler',
99 'filename': os.path.join(BASE_DIR, 'logs/django.log'),
100 'formatter': 'verbose'
101 },
102 'console': {
103 'class': 'logging.StreamHandler',
104 'stream': sys.stdout,
105 }
106 },
107 'loggers': {
108 'jutil': {
109 'handlers': ['file', 'console'],
110 'level': 'DEBUG',
111 },
112 'django': {
113 'handlers': ['file', 'console'],
114 'level': 'WARNING',
115 },
116 }
117}
119# Password validation
120# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
122AUTH_PASSWORD_VALIDATORS = [
123 {
124 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
125 },
126 {
127 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
128 },
129 {
130 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
131 },
132 {
133 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
134 },
135]
138# Internationalization
139# https://docs.djangoproject.com/en/3.0/topics/i18n/
141LANGUAGE_CODE = 'en-us'
143TIME_ZONE = 'UTC'
145USE_I18N = True
147USE_L10N = True
149USE_TZ = True
151LOCALE_PATHS = (
152 os.path.join(BASE_DIR, 'jutil/locale'),
153)
156# Static files (CSS, JavaScript, Images)
157# https://docs.djangoproject.com/en/3.0/howto/static-files/
159STATIC_URL = '/static/'
160STATIC_ROOT = os.path.join(BASE_DIR, 'static')
162STATICFILES_DIRS: Sequence[str] = [
163]
164STATICFILES_FINDERS: Sequence[str] = (
165 'django.contrib.staticfiles.finders.FileSystemFinder',
166 'django.contrib.staticfiles.finders.AppDirectoriesFinder'
167)
169# XML formatting
170XMLLINT_PATH = '/usr/bin/xmllint'