Coverage for project/base_settings.py: 100%

# Coverage for project/base_settings.py : 100%

## 25 statements 25 run 0 missing 0 excluded 0 partial

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"""

2 Django settings for project project.

3

4 Generated by 'django-admin startproject' using Django 3.0.4.

5

6 For more information on this file, see

7 https://docs.djangoproject.com/en/3.0/topics/settings/

8

9 For the full list of settings and their values, see

10 https://docs.djangoproject.com/en/3.0/ref/settings/

11"""

12

13 import os

14

15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

16 import sys

17 from typing import Sequence

18

19 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

20 MEDIA_ROOT = BASE_DIR

21

22

23# Quick-start development settings - unsuitable for production

24# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

25

26# SECURITY WARNING: don't run with debug turned on in production!

27 DEBUG = False

28

29 ALLOWED_HOSTS: Sequence[str] = []

30

31

32# Application definition

33

34 INSTALLED_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]

45

46 MIDDLEWARE = [

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]

55

56 ROOT_URLCONF = 'project.urls'

57

58 TEMPLATES = [

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]

73

74 WSGI_APPLICATION = 'project.wsgi.application'

75

76# Logging

77

78 LOGGING = {

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}

118

119# Password validation

120# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

121

122 AUTH_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]

136

137

138# Internationalization

139# https://docs.djangoproject.com/en/3.0/topics/i18n/

140

141 LANGUAGE_CODE = 'en-us'

142

143 TIME_ZONE = 'UTC'

144

145 USE_I18N = True

146

147 USE_L10N = True

148

149 USE_TZ = True

150

151 LOCALE_PATHS = (

152 os.path.join(BASE_DIR, 'jutil/locale'),

153)

154

155

156# Static files (CSS, JavaScript, Images)

157# https://docs.djangoproject.com/en/3.0/howto/static-files/

158

159 STATIC_URL = '/static/'

160 STATIC_ROOT = os.path.join(BASE_DIR, 'static')

161

162 STATICFILES_DIRS: Sequence[str] = [

163]

164 STATICFILES_FINDERS: Sequence[str] = (

165 'django.contrib.staticfiles.finders.FileSystemFinder',

166 'django.contrib.staticfiles.finders.AppDirectoriesFinder'

167)

168

169# XML formatting

170 XMLLINT_PATH = '/usr/bin/xmllint'