其中a是django表單中的標準錯誤消息?標準django表單錯誤消息
我如何在自定義驗證中使用它們?
我的意思是像 '這個字段是必須的'
由於錯誤
編輯:
目前我這樣做:
def clean(self):
cleaned_data = super(QuoteForm, self).clean()
country = cleaned_data['country']
for key in COUNTRY_FIELDS[country]:
if cleaned_data[key] == '':
self._errors[key] = self.error_class(_('This field is required'))
return cleaned_data
固定:我補充 :
self._errors[key] = self.error_class([forms.Field.default_error_messages['required']])
我該如何使用self.error_class()? – maazza
爲什麼不發佈一些代碼來說明你想要做什麼?通常你不應該擔心'error_class'。 –
好吧忘了它必須作爲一個列表傳遞 – maazza