0
這裏是如何MinLengthValidator在Django的定義:Django的:改變MinLengthValidator錯誤消息
class MinLengthValidator(BaseValidator):
compare = lambda self, a, b: a < b
clean = lambda self, x: len(x)
message = ungettext_lazy(
'Ensure this value has at least %(limit_value)d character (it has %(show_value)d).',
'Ensure this value has at least %(limit_value)d characters (it has %(show_value)d).',
'limit_value')
code = 'min_length'
我試着在我的代碼更改錯誤信息是這樣的:
password_min_length_validator = MinLengthValidator(8)
password_min_length_validator.message = ungettext_lazy(
'Ensure password has at least %(limit_value)d character (it has %(show_value)d).',
'Ensure password has at least %(limit_value)d characters (it has %(show_value)d).',
'limit_value')
但我得到這個錯誤:
ugettext() takes exactly 1 argument (3 given)
我這樣做就像django.core.validators那樣做。
請提供完整的堆棧跟蹤。 – Serafeim