🧑‍💻(user) fix the User.language

The use of a lazy function here make the Django migration
detector to generate a migration every time we run `makemigrations`.
This is not mandatory to have a lazy here as the settings are loaded
once at runtime beginning.
As the choices makes noop migrations, we directly use the setting in
the initial migration.
This commit is contained in:
Quentin BEY
2024-12-18 17:42:14 +01:00
committed by BEY Quentin
parent e60bae4321
commit 469014ac41
3 changed files with 6 additions and 3 deletions

View File

@@ -21,7 +21,6 @@ from django.core.exceptions import ValidationError
from django.db import models, transaction
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.functional import lazy
from django.utils.translation import gettext_lazy as _
from django.utils.translation import override
@@ -441,7 +440,7 @@ class User(AbstractBaseUser, BaseModel, auth_models.PermissionsMixin):
name = models.CharField(_("name"), max_length=100, null=True, blank=True)
language = models.CharField(
max_length=10,
choices=lazy(lambda: settings.LANGUAGES, tuple)(),
choices=settings.LANGUAGES,
default=settings.LANGUAGE_CODE,
verbose_name=_("language"),
help_text=_("The language in which the user wants to see the interface."),