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 authored and Veiko Aasa committed 2025-01-07 11:45:57 +02:00
1 parent 9b8b0cd254
commit 2f0ec1a1cd
1 file changed
+8
+8
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):