mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-24 01:28:42 +02:00
test
This commit is contained in:
@@ -65,7 +65,7 @@ INSTALLED_APPS = [
|
|||||||
"apps.common.apps.CommonConfig",
|
"apps.common.apps.CommonConfig",
|
||||||
"apps.net_worth.apps.NetWorthConfig",
|
"apps.net_worth.apps.NetWorthConfig",
|
||||||
"apps.api.apps.ApiConfig",
|
"apps.api.apps.ApiConfig",
|
||||||
# "cachalot",
|
"cachalot",
|
||||||
"rest_framework",
|
"rest_framework",
|
||||||
"drf_spectacular",
|
"drf_spectacular",
|
||||||
]
|
]
|
||||||
@@ -258,3 +258,7 @@ SPECTACULAR_SETTINGS = {
|
|||||||
"SERVE_INCLUDE_SCHEMA": False,
|
"SERVE_INCLUDE_SCHEMA": False,
|
||||||
# OTHER SETTINGS
|
# OTHER SETTINGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# CACHALOT_CACHE_RANDOM = True
|
||||||
|
# CACHALOT_QUERY_KEYGEN = "cachalot.utils.get_query_cache_key"
|
||||||
|
# CACHALOT_TIMEOUT = 60 * 60 * 24 # 24 hours, or adjust as needed
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import zoneinfo
|
|||||||
from django.utils import timezone, translation
|
from django.utils import timezone, translation
|
||||||
from django.utils.cache import patch_vary_headers
|
from django.utils.cache import patch_vary_headers
|
||||||
from django.utils.translation import activate
|
from django.utils.translation import activate
|
||||||
|
from cachalot.api import invalidate
|
||||||
|
|
||||||
|
|
||||||
class LocalizationMiddleware:
|
class LocalizationMiddleware:
|
||||||
@@ -32,6 +33,14 @@ class LocalizationMiddleware:
|
|||||||
else:
|
else:
|
||||||
language_to_activate = translation.get_language_from_request(request)
|
language_to_activate = translation.get_language_from_request(request)
|
||||||
|
|
||||||
|
# Check if timezone or language has changed
|
||||||
|
if (
|
||||||
|
getattr(request, "timezone", None) != timezone_to_activate
|
||||||
|
or getattr(request, "language", None) != language_to_activate
|
||||||
|
):
|
||||||
|
# Invalidate cachalot cache
|
||||||
|
invalidate()
|
||||||
|
|
||||||
# Apply timezone and language to the request
|
# Apply timezone and language to the request
|
||||||
request.timezone = timezone_to_activate
|
request.timezone = timezone_to_activate
|
||||||
request.language = language_to_activate
|
request.language = language_to_activate
|
||||||
|
|||||||
Reference in New Issue
Block a user