neptune/app/settings.py

191 lines
5.0 KiB
Python
Raw Normal View History

2022-07-21 12:44:57 +00:00
"""
Django settings for app project.
Generated by 'django-admin startproject' using Django 4.0.6.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
import os
2022-07-21 12:44:57 +00:00
from pathlib import Path
# 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/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# MOVED TO local_settings.py
2022-07-21 12:44:57 +00:00
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
2022-07-21 12:49:43 +00:00
"core",
2022-07-21 12:45:13 +00:00
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
2022-09-05 06:20:30 +00:00
"debug_toolbar",
"template_profiler_panel",
2022-08-09 08:04:31 +00:00
"django_htmx",
"crispy_forms",
2022-07-21 12:49:06 +00:00
"crispy_bulma",
2022-08-09 08:04:31 +00:00
"django_tables2",
"django_tables2_bulma_template",
2023-02-09 19:07:49 +00:00
"prettyjson",
2022-07-21 12:44:57 +00:00
]
2022-07-21 12:49:06 +00:00
CRISPY_TEMPLATE_PACK = "bulma"
CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
2022-08-09 08:04:31 +00:00
DJANGO_TABLES2_TEMPLATE = "django-tables2/bulma.html"
2022-07-21 12:44:57 +00:00
MIDDLEWARE = [
2022-09-05 06:20:30 +00:00
"debug_toolbar.middleware.DebugToolbarMiddleware",
2022-07-21 12:45:13 +00: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",
2022-08-09 08:04:31 +00:00
"django_htmx.middleware.HtmxMiddleware",
2022-07-21 12:44:57 +00:00
]
2022-07-21 12:45:13 +00:00
ROOT_URLCONF = "app.urls"
2022-07-21 12:44:57 +00:00
TEMPLATES = [
{
2022-07-21 12:45:13 +00:00
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "core/templates")],
2022-07-21 12:45:13 +00:00
"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",
2022-07-21 12:44:57 +00:00
],
},
},
]
2022-07-21 12:45:13 +00:00
WSGI_APPLICATION = "app.wsgi.application"
2022-07-21 12:44:57 +00:00
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
2022-07-21 12:45:13 +00:00
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
2022-07-21 12:44:57 +00:00
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
2022-07-21 12:45:13 +00:00
{"NAME": f"django.contrib.auth.password_validation.{name}"}
for name in [
"UserAttributeSimilarityValidator",
"MinimumLengthValidator",
"CommonPasswordValidator",
"NumericPasswordValidator",
]
2022-07-21 12:44:57 +00:00
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
2022-07-21 12:45:13 +00:00
LANGUAGE_CODE = "en-us"
2022-07-21 12:44:57 +00:00
2022-07-21 12:45:13 +00:00
TIME_ZONE = "UTC"
2022-07-21 12:44:57 +00:00
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
2022-07-21 12:47:42 +00:00
STATIC_URL = "static/"
2022-07-21 12:44:57 +00:00
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
2022-07-21 12:45:13 +00:00
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
AUTH_USER_MODEL = "core.User"
2022-07-21 12:49:43 +00:00
LOGIN_REDIRECT_URL = "home"
LOGOUT_REDIRECT_URL = "home"
LOGIN_URL = "/accounts/login/"
# ALLOWED_PAYMENT_METHODS = ["bacs_debit", "card"]
ALLOWED_PAYMENT_METHODS = ["card"]
2022-07-21 12:48:39 +00:00
REST_FRAMEWORK = {
"DEFAULT_PARSER_CLASSES": [
"rest_framework.parsers.JSONParser",
]
}
2022-09-05 06:20:30 +00:00
INTERNAL_IPS = [
"127.0.0.1",
2022-09-05 06:20:30 +00:00
"10.1.10.11",
2022-09-05 06:20:30 +00:00
]
DEBUG_TOOLBAR_PANELS = [
"template_profiler_panel.panels.template.TemplateProfilerPanel",
"debug_toolbar.panels.history.HistoryPanel",
"debug_toolbar.panels.versions.VersionsPanel",
"debug_toolbar.panels.timer.TimerPanel",
"debug_toolbar.panels.settings.SettingsPanel",
"debug_toolbar.panels.headers.HeadersPanel",
"debug_toolbar.panels.request.RequestPanel",
"debug_toolbar.panels.sql.SQLPanel",
"debug_toolbar.panels.staticfiles.StaticFilesPanel",
"debug_toolbar.panels.templates.TemplatesPanel",
"debug_toolbar.panels.cache.CachePanel",
"debug_toolbar.panels.signals.SignalsPanel",
"debug_toolbar.panels.logging.LoggingPanel",
"debug_toolbar.panels.redirects.RedirectsPanel",
"debug_toolbar.panels.profiling.ProfilingPanel",
2022-09-05 06:20:30 +00:00
]
from app.local_settings import * # noqa
2022-08-02 16:10:41 +00:00
if PROFILER: # noqa - trust me its there
2022-08-02 21:22:22 +00:00
import pyroscope
2022-08-02 16:10:41 +00:00
2022-08-02 21:22:22 +00:00
pyroscope.configure(
2022-08-02 16:10:41 +00:00
application_name="neptune",
server_address="http://pyroscope:4040",
auth_token=os.getenv("PYROSCOPE_AUTH_TOKEN", ""),
2022-08-02 21:22:22 +00:00
# tags = {
# "region": f'{os.getenv("REGION")}',
# }
2022-08-02 16:10:41 +00:00
)
2023-02-10 07:20:12 +00:00
def show_toolbar(request):
return DEBUG # noqa: from local imports
DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK": show_toolbar,
}