web_framework: Disable caching templates files in development mode

- When a template page is updated, we are having to restart service in order for
the new changes to reflect. This is due to caching of template files starting
Django 4.1[1]. Disable this behavior in development mode to allow reload the
browser page to see changes reflected.

Links:

https://docs.djangoproject.com/en/5.0/releases/4.1/#templates

Tests:

- Change a template file and reload the page without restarting service. The
changes should reflect immediately.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2025-01-04 16:46:21 -08:00 committed by Veiko Aasa
parent 9b8b0cd254
commit 2f0ec1a1cd
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -45,6 +45,14 @@ def init():
settings.STATIC_URL = '/'.join([cfg.server_dir,
'static/']).replace('//', '/')
settings.USE_X_FORWARDED_HOST = cfg.use_x_forwarded_host
if cfg.develop:
# Disable template caching in development so that page updates don't
# require service restart.
del settings.TEMPLATES[0]['APP_DIRS']
settings.TEMPLATES[0]['OPTIONS']['loaders'] = [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]
kwargs = {}
for setting in dir(settings):