Fixes #21175: Use gettext_lazy in data.py for stable migrations #567

Closed
opened 2026-04-05 16:44:11 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 1/15/2026

Fixes: #21175

This PR replaces gettext() with gettext_lazy() in core/data.py so translated validator/validation messages are not evaluated at import time.
This prevents locale-dependent model serialization, which can lead Django to report false-positive “pending migration” warnings when DEFAULT_LANGUAGE is set to a non-English locale.

It also updates one missing ValidationError message to be properly translatable and safe to format.

Reproducer and background discussion: https://github.com/netbox-community/netbox/discussions/21108

*Originally created by @pheus on 1/15/2026* ### Fixes: #21175 This PR replaces `gettext()` with `gettext_lazy()` in `core/data.py` so translated validator/validation messages are not evaluated at import time. This prevents locale-dependent model serialization, which can lead Django to report false-positive “pending migration” warnings when `DEFAULT_LANGUAGE` is set to a non-English locale. It also updates one missing `ValidationError` message to be properly translatable and safe to format. Reproducer and background discussion: https://github.com/netbox-community/netbox/discussions/21108
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#567