Skip to content

Commit 421da0a

Browse files
authored
fix: Correctly handle Django lazy translation objects. (#37155)
1 parent 910c9e6 commit 421da0a

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

openedx/core/djangoapps/util/management/commands/dump_settings.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from django.conf import settings
99
from django.core.management.base import BaseCommand
10-
10+
from django.utils.functional import Promise
1111

1212
SETTING_NAME_REGEX = re.compile(r'^[A-Z][A-Z0-9_]*$')
1313

@@ -78,10 +78,11 @@ def _to_json_friendly_repr(value: object) -> object:
7878
if not isinstance(subkey, (str, int)):
7979
raise ValueError(f"Unexpected dict key {subkey} of type {type(subkey)}")
8080
return {subkey: _to_json_friendly_repr(subval) for subkey, subval in value.items()}
81-
if proxy_args := getattr(value, "_proxy____args", None):
82-
if len(proxy_args) == 1 and isinstance(proxy_args[0], str):
83-
# Print gettext_lazy as simply the wrapped string
84-
return proxy_args[0]
81+
82+
# Directly convert Promise objects (gettext_lazy) to their string representation
83+
if isinstance(value, Promise):
84+
return str(value)
85+
8586
try:
8687
module = value.__module__
8788
qualname = value.__qualname__

0 commit comments

Comments
 (0)