Coverage for library\settings.py: 100%
32 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-06-29 10:02 +0100
« prev ^ index » next coverage.py v7.4.4, created at 2024-06-29 10:02 +0100
1from pathlib import Path
2import os
3import sys
4import dj_database_url
6if os.path.isfile('env.py'):
7 import env
9# This syntax allow you never to have to worry about the value of the
10# DJANGO_DEBUG environment variable.
11# while development, it is allways True, while production it is allways False
12# you may need to change it in case you want to test the production environment
13# locally
14DEBUG = os.environ.get('DJANGO_DEBUG', 'True') == 'True'
15LOGIN_REDIRECT_URL = 'books'
16ROOT_URLCONF = 'library.urls'
17WSGI_APPLICATION = 'library.wsgi.application'
18SITE_ID = 1
19ACCOUNT_EMAIL_VERIFICATION = 'none'
21# SECURITY WARNING: keep the secret key used in production secret!
22SECRET_KEY = os.environ.get('SECRET_KEY')
24# Default primary key field type
25# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
26DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
28# Build paths inside the project like this: BASE_DIR / 'subdir'.
29BASE_DIR = Path(__file__).resolve().parent.parent
30TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
31CSRF_TRUSTED_ORIGINS = ["https://*.codeanyapp.com", "https://*.herokuapp.com"]
32ALLOWED_HOSTS = [".herokuapp.com", "127.0.0.1", "localhost"]
34# Internationalization
35# https://docs.djangoproject.com/en/4.2/topics/i18n/
36USE_TZ = True
37USE_I18N = True
38TIME_ZONE = 'UTC'
39LANGUAGE_CODE = 'en-us'
41# Static files (CSS, JavaScript, Images)
42# https://docs.djangoproject.com/en/4.2/howto/static-files/
43STATIC_URL = 'static/'
44STATICFILES_DIRS = [os.path.join(BASE_DIR, STATIC_URL), ]
45STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
47# Application definition
48INSTALLED_APPS = [
49 'django.contrib.admin',
50 'django.contrib.auth',
51 'django.contrib.contenttypes',
52 'django.contrib.sessions',
53 'django.contrib.messages',
54 'django.contrib.staticfiles',
55 'cloudinary_storage',
56 'django.contrib.sites',
57 'allauth',
58 'allauth.account',
59 'allauth.socialaccount',
60 'cloudinary',
61 'book.apps.BookConfig',
62 'author.apps.AuthorConfig',
63 'reader.apps.ReaderConfig',
64]
66MIDDLEWARE = [
67 'django.middleware.security.SecurityMiddleware',
68 'whitenoise.middleware.WhiteNoiseMiddleware',
69 'django.contrib.sessions.middleware.SessionMiddleware',
70 'django.middleware.common.CommonMiddleware',
71 'django.middleware.csrf.CsrfViewMiddleware',
72 'django.contrib.auth.middleware.AuthenticationMiddleware',
73 'django.contrib.messages.middleware.MessageMiddleware',
74 'django.middleware.clickjacking.XFrameOptionsMiddleware',
75 'allauth.account.middleware.AccountMiddleware',
76]
78TEMPLATES = [
79 {
80 'BACKEND': 'django.template.backends.django.DjangoTemplates',
81 'DIRS': [TEMPLATES_DIR],
82 'APP_DIRS': True,
83 'OPTIONS': {
84 'context_processors': [
85 'django.template.context_processors.debug',
86 'django.template.context_processors.request',
87 'django.contrib.auth.context_processors.auth',
88 'django.contrib.messages.context_processors.messages',
89 ],
90 },
91 },
92]
94DATABASES = {
95 'default': dj_database_url.parse(os.environ.get("DATABASE_URL"))
96}
98if 'test' in sys.argv:
99 DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
101# Password validation
102# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
103AUTH_PASSWORD_VALIDATORS = [
104 {
105 'NAME': 'django.contrib.auth.password_validation'
106 '.UserAttributeSimilarityValidator',
107 },
108 {
109 'NAME': 'django.contrib.auth.password_validation'
110 '.MinimumLengthValidator',
111 },
112 {
113 'NAME': 'django.contrib.auth.password_validation'
114 '.CommonPasswordValidator',
115 },
116 {
117 'NAME': 'django.contrib.auth.password_validation'
118 '.NumericPasswordValidator',
119 },
120]