From c882f1386c031a4a337206b356b8223da5cd37e4 Mon Sep 17 00:00:00 2001 From: Samuel Paccoud - DINUM Date: Mon, 27 Jan 2025 23:27:23 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(backend)=20remove=20lazy=20f?= =?UTF-8?q?rom=20languages=20field=20on=20User=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The idea behind wrapping choices in `lazy` function was to allow overriding the list of languages in tests with `override_settings`. This was causin makemigrations to keep on including the field in migrations when it is not needed. Since we finally don't override the LANGUAGES setting in tests, we can remove it to fix the problem. --- src/backend/core/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 83405bae..ef276d02 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -24,7 +24,7 @@ from django.db import models, transaction from django.db.models.functions import Left, Length from django.template.loader import render_to_string from django.utils import timezone -from django.utils.functional import cached_property, lazy +from django.utils.functional import cached_property from django.utils.translation import get_language, override from django.utils.translation import gettext_lazy as _ @@ -244,7 +244,7 @@ class User(AbstractBaseUser, BaseModel, auth_models.PermissionsMixin): language = models.CharField( max_length=10, - choices=lazy(lambda: settings.LANGUAGES, tuple)(), + choices=settings.LANGUAGES, default=None, verbose_name=_("language"), help_text=_("The language in which the user wants to see the interface."),