理解django形式的问题

时间:2011-03-14 21:59:23

标签: django

class UserField(forms.EmailField):
def clean(self, value):
    super(UserField, self).clean(value)
    try:
        User.objects.get(username=value)
        raise forms.ValidationError("There is an existing account associated with this email.")
    except User.DoesNotExist:
        return value

try except方法很简单。但是,我很难搞清楚

super(UserField, self).clean(value)

1 个答案:

答案 0 :(得分:2)

super(UserField, self).clean(value)正在调用祖先方法:forms.EmailField.clean(value)以检查电子邮件是否格式正确。