Add django-redis cache
This commit is contained in:
parent
237343b59b
commit
2390968029
2 changed files with 25 additions and 21 deletions
|
@ -1,24 +1,8 @@
|
||||||
"""
|
|
||||||
Django settings for config project.
|
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 5.1.4.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/5.1/topics/settings/
|
|
||||||
|
|
||||||
For the full list of settings and their values, see
|
|
||||||
https://docs.djangoproject.com/en/5.1/ref/settings/
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
|
||||||
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = 'django-insecure-$m!a$rjih3i64n8&t3km0u--k0_ij5-a6t!(n_nbz1$)$%0lqn'
|
SECRET_KEY = 'django-insecure-$m!a$rjih3i64n8&t3km0u--k0_ij5-a6t!(n_nbz1$)$%0lqn'
|
||||||
|
|
||||||
|
@ -27,9 +11,9 @@ DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
INTERNAL_IPS = ['localhost', '127.0.0.1',]
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
|
@ -114,7 +98,9 @@ TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
USE_TZ = True
|
#USE_TZ = True
|
||||||
|
USE_TZ = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
@ -141,8 +127,25 @@ MEDIA_ROOT = BASE_DIR / 'media'
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
|
||||||
# Session lifetime 1 year
|
# Sessions
|
||||||
SESSION_COOKIE_AGE = 31556000
|
SESSION_COOKIE_AGE = 60 * 60 * 24 * 365 * 5 # 5 vuotta
|
||||||
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
|
||||||
|
SESSION_COOKIE_SECURE = True
|
||||||
|
SESSION_COOKIE_SAMESITE = 'Lax'
|
||||||
|
|
||||||
|
# Sessio backend: cache + fallback tietokantaan
|
||||||
|
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
|
||||||
|
|
||||||
|
# Redis cache
|
||||||
|
CACHES = {
|
||||||
|
"default": {
|
||||||
|
"BACKEND": "django_redis.cache.RedisCache",
|
||||||
|
"LOCATION": "redis://127.0.0.1:6379/1",
|
||||||
|
"OPTIONS": {
|
||||||
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Gotify
|
# Gotify
|
||||||
|
@ -195,4 +198,4 @@ LOGGING = {
|
||||||
try:
|
try:
|
||||||
from .local_settings import *
|
from .local_settings import *
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
|
@ -1,6 +1,7 @@
|
||||||
Django==5.1.7
|
Django==5.1.7
|
||||||
django_cleanup==9.0.0
|
django_cleanup==9.0.0
|
||||||
django_imagekit==5.0.0
|
django_imagekit==5.0.0
|
||||||
|
django-redis==5.4.0
|
||||||
Pillow==11.1.0
|
Pillow==11.1.0
|
||||||
pytz==2025.2
|
pytz==2025.2
|
||||||
Requests==2.32.3
|
Requests==2.32.3
|
||||||
|
|
Loading…
Add table
Reference in a new issue