From 198d68e6ffdbbd6a56de299a6811603581d2ceb3 Mon Sep 17 00:00:00 2001 From: Bernard Siebens Date: Sun, 7 Jun 2026 16:18:02 +0200 Subject: [PATCH] Defer constance config reads in Season.generate_default to avoid DB access at import time Co-Authored-By: Claude Sonnet 4.6 --- teams/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/teams/models.py b/teams/models.py index 60dd451..8f07eda 100644 --- a/teams/models.py +++ b/teams/models.py @@ -58,7 +58,13 @@ class Season(RulesModel): return season @classmethod - def generate_default(cls, day: int = config.TF_DEFAULT_SEASON_DAY, month: int = config.TF_DEFAULT_SEASON_MONTH, duration: str = config.TF_DEFAULT_SEASON_DURATION) -> "Season": + def generate_default(cls, day: int | None = None, month: int | None = None, duration: str | None = None) -> "Season": + if day is None: + day = config.TF_DEFAULT_SEASON_DAY + if month is None: + month = config.TF_DEFAULT_SEASON_MONTH + if duration is None: + duration = config.TF_DEFAULT_SEASON_DURATION current_year = timezone.now().date().year start_date = datetime.date(current_year, month, day)