2010-12-16 53 views

回答

0

如果您想自定義消息多一點,你還可以:

from django.core.exceptions import ValidationError 

def my_validator(value): 
    if not len(value): 
     raise ValidationError('Your error message here!') 

然後,在你的models.py:

from django import forms 

class MyForm(forms.Form): 
    my_field= forms.CharField(validators=[my_validator]) 
相關問題