как убрать ошибку NameError: name '_' is not defined
?
models.py
from django.core.exceptions import ValidationError
import phonenumbers
def validate_phone_number(value):
try:
z = phonenumbers.parse(value, None)
except phonenumbers.NumberParseException:
raise ValidationError(_('%(value) is not a valid phone number'), params={'value': value},)
if not phonenumbers.is_valid_number(z):
raise ValidationError(_('%(value) is not a valid phone number'),params={'value': value},)
class Storehouses(models.Model):
phone = models.CharField(validators=[validate_phone_number], unique=True, max_length=17, verbose_name='Телефон')
from django.utils.translation import gettext as _
docs.djangoproject.com/en/dev/topics/i18n/translation