Create json config file & update templates

This commit is contained in:
Nyymix 2025-04-06 16:24:50 +03:00
parent 2f4a23b600
commit c0b47b0739
12 changed files with 80 additions and 63 deletions

View file

@ -0,0 +1,21 @@
import json
from pathlib import Path
from django.conf import settings
from django.core.cache import cache
def site_config(request):
config = cache.get('site_config')
if not config:
config_path = Path(settings.BASE_DIR) / 'config' / 'site_config.json'
try:
with open(config_path, 'r') as f:
config = json.load(f)
cache.set('site_config', config, 3600)
except FileNotFoundError:
config = {}
return {'site_config': config}