I'm using ugettext_lazy in a model validator to return the proper message to the frontend with the right language but it is not working.
from django.utils.translation import ugettext_lazy as _
class User(AbstractUser, BaseModel):
mobile_number = models.CharField(
'Mobile Number',
validators=[
RegexValidator(
regex=r'^A Validator regex',
message=_('Mobile Number is not Valid'),
code='invalid_mobile',
)
],
max_length=32,
blank=True,
)
I am using Django Rest Framework and some of the errors are handled in the serizliers and the ugettext_lazy is working properly in the serializer errors but when it comes to the model messages, the translation is not working and it returns the English version of the error.