repos
/ analytics-django master

analytics-django

mirror archived upstream

Self-hostable website analytics on Django: a straightforward collector API, dashboards, a world map, and PDF reports.

analyticsdjangodockerhandcodedpythonself-hostedsqliteviteweb-analytics

1.8 KB · 87 lines · Python Raw History
 1import os
 2
 3from . import *  # noqa
 4
 5
 6# Custom settings
 7
 8BASE_URL = os.environ.get("DJANGO_BASE_URL")
 9
10
11# Core settings
12# https://docs.djangoproject.com/en/4.0/ref/settings/#core-settings
13
14ALLOWED_HOSTS = [os.environ.get("DJANGO_BASE_URL").split("//")[1]]
15
16
17# Debuggging
18# https://docs.djangoproject.com/en/4.0/ref/settings/#debugging
19
20DEBUG = False
21
22
23# HTTP
24# https://docs.djangoproject.com/en/4.0/ref/settings/#http
25
26SECURE_BROWSER_XSS_FILTER = True
27SECURE_HSTS_INCLUDE_SUBDOMAINS = True
28SECURE_HSTS_PRELOAD = True
29SECURE_HSTS_SECONDS = 31536000
30SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
31SECURE_SSL_REDIRECT = True
32USE_X_FORWARDED_HOST = True
33
34
35# Security
36# https://docs.djangoproject.com/en/4.0/ref/settings/#security
37
38CSRF_COOKIE_SECURE = True
39CSRF_TRUSTED_ORIGINS = [os.environ.get("DJANGO_BASE_URL")]
40SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY")
41SESSION_COOKIE_SECURE = True
42
43
44# Database
45# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
46
47DATABASES["default"]["NAME"] = "/data/db/db.sqlite3"
48
49
50# Media files (Images, Videos)
51# https://docs.djangoproject.com/en/4.0/ref/settings/#media-root
52
53MEDIA_URL = BASE_URL + "/media/"
54MEDIA_ROOT = "/data/media"
55
56
57# Email
58# https://docs.djangoproject.com/en/4.0/topics/email/#email-backends
59
60EMAIL_BACKEND = "analytics.mailer.DirectMXBackend"
61DEFAULT_FROM_EMAIL = "[email protected]"
62SERVER_EMAIL = "[email protected]"
63
64
65# Logging
66# https://docs.djangoproject.com/en/4.0/topics/logging/
67
68LOGGING = {
69    "version": 1,
70    "disable_existing_loggers": False,
71    "handlers": {
72        "console": {
73            "class": "logging.StreamHandler",
74        },
75    },
76    "root": {
77        "handlers": ["console"],
78        "level": "WARNING",
79    },
80}
81
82
83# GeoIP2
84# https://docs.djangoproject.com/en/4.0/ref/contrib/gis/geoip2/#std-setting-GEOIP_PATH
85
86GEOIP_PATH = "/data/db.mmdb"