我想驗證我的表單。這是我的代碼。驗證django python允許的字符數
class SMSTemplateForm(forms.ModelForm):
def clean(self):
template_format = self.cleaned_data.get('template_form')
if len(template_format) > 160:
raise forms.ValidationError('SMS content too long.')
return self.cleaned_data
請修復您的縮進。內部Meta類內部是乾淨的方法。 –
對不起,只是修復 – Patcho