Skip to content

Commit

Permalink
fix: Apply force_str only to Promise
Browse files Browse the repository at this point in the history
Refs #701
  • Loading branch information
last-partizan committed Sep 8, 2023
1 parent 3295626 commit e7640c7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modeltranslation/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.db.models import fields
from django.utils.encoding import force_str
from django.utils.functional import Promise
from django.utils.translation import override

from modeltranslation import settings as mt_settings
Expand Down Expand Up @@ -267,7 +268,9 @@ def get_default(self):
#
# force_str passes protected types as-is, which includes None, int, float,
# datetime...
return force_str(default, strings_only=True)
if isinstance(default, Promise):
default = force_str(default, strings_only=True)
return default

def formfield(self, *args, **kwargs):
"""
Expand Down

0 comments on commit e7640c7

Please sign in to comment.