From a2a0097996fc53fb4e452a8a4ce6969d51183d43 Mon Sep 17 00:00:00 2001 From: Martin Hauser Date: Thu, 15 Jan 2026 13:43:13 +0100 Subject: [PATCH] fix(core): Use gettext_lazy in data.py Replace `gettext()` with `gettext_lazy()` to avoid locale-dependent model serialization (and false-positive pending migration warnings). Also make a missing `ValidationError` message translatable and format-safe. Fixes #21175 --- netbox/core/models/data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/netbox/core/models/data.py b/netbox/core/models/data.py index 78adb14f5..7565a7a20 100644 --- a/netbox/core/models/data.py +++ b/netbox/core/models/data.py @@ -12,7 +12,7 @@ from django.core.validators import RegexValidator from django.db import models from django.urls import reverse from django.utils import timezone -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from netbox.constants import CENSOR_TOKEN, CENSOR_TOKEN_CHANGED from netbox.models import PrimaryModel @@ -128,7 +128,9 @@ class DataSource(JobsMixin, PrimaryModel): # Ensure URL scheme matches selected type if self.backend_class.is_local and self.url_scheme not in ('file', ''): raise ValidationError({ - 'source_url': "URLs for local sources must start with file:// (or specify no scheme)" + 'source_url': _("URLs for local sources must start with {scheme} (or specify no scheme)").format( + scheme='file://' + ) }) def save(self, *args, **kwargs):