From 7d88b40fa753d934f638e0ab97f5e74a95952c1d Mon Sep 17 00:00:00 2001 From: Kara Engelhardt Date: Mon, 1 Jun 2026 14:02:36 +0200 Subject: [PATCH] Add pretix.cfg to django autoreloader files --- src/pretix/settings.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pretix/settings.py b/src/pretix/settings.py index 646972af7e..6153c30ac3 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -58,10 +58,11 @@ from django.utils.translation import gettext_lazy as _ # NOQA _config = configparser.RawConfigParser() if 'PRETIX_CONFIG_FILE' in os.environ: - _config.read_file(open(os.environ.get('PRETIX_CONFIG_FILE'), encoding='utf-8')) + config_files = [os.environ['PRETIX_CONFIG_FILE']] else: - _config.read(['/etc/pretix/pretix.cfg', os.path.expanduser('~/.pretix.cfg'), 'pretix.cfg'], - encoding='utf-8') + config_files = ['/etc/pretix/pretix.cfg', os.path.expanduser('~/.pretix.cfg'), 'pretix.cfg'] + +_config.read(config_files, encoding='utf-8') config = EnvOrParserConfig(_config) CONFIG_FILE = config @@ -895,3 +896,14 @@ VITE_DEV_SERVER = f"http://localhost:{VITE_DEV_SERVER_PORT}" VITE_DEV_MODE = DEBUG VITE_IGNORE = False # Used to ignore `collectstatic`/`rebuild` PRETIX_WIDGET_VITE = os.environ.get('PRETIX_WIDGET_VITE', '') not in ('', '0') + +if DEBUG: + # Reload if settings file changes + config_files_to_watch = [Path(x).absolute() for x in config_files] + + from django.utils.autoreload import autoreload_started, BaseReloader + from django.dispatch import receiver + + @receiver(autoreload_started, dispatch_uid="pretix_watch_config_file") + def watch_config_file(sender: BaseReloader, *args, **kwargs): + sender.extra_files.update(config_files_to_watch)