Debian Codegraph @

examples/react-spa/backend/backend/settings.py

raw
1 from pathlib import Path
2
3
4 # Build paths inside the project like this: BASE_DIR / 'subdir'.
5 BASE_DIR = Path(__file__).resolve().parent.parent
6
7
8 # Quick-start development settings - unsuitable for production
9 # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
10
11 # SECURITY WARNING: keep the secret key used in production secret!
12 SECRET_KEY = "dummy-secret-key"
13
14 # SECURITY WARNING: don't run with debug turned on in production!
15 DEBUG = True
16
17 ALLOWED_HOSTS = ["localhost", "backend", "127.0.0.1"]
18
19
20 # Application definition
21
22 INSTALLED_APPS = [
23 "django.contrib.admin",
24 "django.contrib.auth",
25 "django.contrib.contenttypes",
26 "django.contrib.sessions",
27 "django.contrib.messages",
28 "django.contrib.staticfiles",
29 "allauth",
30 "allauth.account",
31 "allauth.socialaccount",
32 "allauth.socialaccount.providers.dummy",
33 "allauth.mfa",
34 "allauth.headless",
35 "allauth.usersessions",
36 "drf_spectacular",
37 "backend.drf_demo",
38 "backend.ninja_demo",
39 ]
40
41 MIDDLEWARE = [
42 "django.middleware.security.SecurityMiddleware",
43 "django.contrib.sessions.middleware.SessionMiddleware",
44 "django.middleware.common.CommonMiddleware",
45 "django.middleware.csrf.CsrfViewMiddleware",
46 "django.contrib.auth.middleware.AuthenticationMiddleware",
47 "django.contrib.messages.middleware.MessageMiddleware",
48 "django.middleware.clickjacking.XFrameOptionsMiddleware",
49 "allauth.account.middleware.AccountMiddleware",
50 ]
51
52 ROOT_URLCONF = "backend.urls"
53
54 TEMPLATES = [
55 {
56 "BACKEND": "django.template.backends.django.DjangoTemplates",
57 "DIRS": [],
58 "APP_DIRS": True,
59 "OPTIONS": {
60 "context_processors": [
61 "django.template.context_processors.debug",
62 "django.template.context_processors.request",
63 "django.contrib.auth.context_processors.auth",
64 "django.contrib.messages.context_processors.messages",
65 ],
66 },
67 },
68 ]
69
70 WSGI_APPLICATION = "backend.wsgi.application"
71
72
73 # Database
74 # https://docs.djangoproject.com/en/4.2/ref/settings/#databases
75
76 DATABASES = {
77 "default": {
78 "ENGINE": "django.db.backends.sqlite3",
79 "NAME": BASE_DIR / "db.sqlite3",
80 }
81 }
82
83
84 # Password validation
85 # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
86
87 AUTH_PASSWORD_VALIDATORS = [
88 {
89 "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
90 },
91 {
92 "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
93 },
94 {
95 "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
96 },
97 {
98 "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
99 },
100 ]
101
102
103 # Internationalization
104 # https://docs.djangoproject.com/en/4.2/topics/i18n/
105
106 LANGUAGE_CODE = "en-us"
107
108 TIME_ZONE = "UTC"
109
110 USE_I18N = True
111
112 USE_TZ = True
113
114
115 # Static files (CSS, JavaScript, Images)
116 # https://docs.djangoproject.com/en/4.2/howto/static-files/
117
118 STATIC_URL = "static/"
119
120 # Default primary key field type
121 # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
122
123 DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
124
125 EMAIL_HOST = "mail"
126 EMAIL_PORT = 1025
127
128 AUTHENTICATION_BACKENDS = ("allauth.account.auth_backends.AuthenticationBackend",)
129
130 ACCOUNT_EMAIL_VERIFICATION = "mandatory"
131 ACCOUNT_LOGIN_METHODS = {"email"}
132 ACCOUNT_LOGOUT_ON_PASSWORD_CHANGE = False
133 ACCOUNT_LOGIN_BY_CODE_ENABLED = True
134 ACCOUNT_EMAIL_VERIFICATION_BY_CODE_ENABLED = True
135 ACCOUNT_SIGNUP_FIELDS = ["email*", "password1*", "password2*"]
136
137 HEADLESS_ONLY = True
138 HEADLESS_FRONTEND_URLS = {
139 "account_confirm_email": "/account/verify-email/{key}",
140 "account_reset_password": "/account/password/reset",
141 "account_reset_password_from_key": "/account/password/reset/key/{key}",
142 "account_signup": "/account/signup",
143 "socialaccount_login_error": "/account/provider/callback",
144 }
145 HEADLESS_SERVE_SPECIFICATION = True
146
147 MFA_SUPPORTED_TYPES = ["totp", "recovery_codes", "webauthn"]
148 MFA_PASSKEY_LOGIN_ENABLED = True
149 MFA_PASSKEY_SIGNUP_ENABLED = True
150
151 REST_FRAMEWORK = {
152 "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
153 }
154 SPECTACULAR_SETTINGS = {
155 "EXTERNAL_DOCS": {"description": "allauth", "url": "/_allauth/openapi.html"},
156 }
157
158
159 try:
160 from .local_settings import * # noqa
161 except ImportError:
162 pass