def clean_email(self):
""" Validate that the e-mail address is unique. """
if User.objects.filter(email__iexact=self.cleaned_data['email']):
raise forms.ValidationError(_('This email is already in use. Please supply a different email.'))
return self.cleaned_data['email']
与检查电子邮件是否被其他用户使用相比。对于花名册,如果在花名册表中找不到,我们将提出错误。你知道吗
def clean_email(self):
""" Validate that the e-mail address is unique. """
if User.objects.filter(email__iexact=self.cleaned_data['email']):
raise forms.ValidationError(_('This email is already in use. Please supply a different email.'))
if not Roster.objects.filter(email__iexact=self.cleaned_data['email']):
raise forms.ValidationError(_('You are not able to signup as you are not part of the Roster.'))
return self.cleaned_data['email']
在用户ena.forms是报名表。我将扩展表单验证中正在实现的三个干净方法之一。这些是干净的用户名,干净的电子邮件和干净的。你知道吗
例如,下面是clean\u email方法。它已经检查电子邮件是否已经被使用。我会维护一个包含有效电子邮件的花名册表。因此,您可以添加另一层检查。我会把它放在第一个下面。你知道吗
与检查电子邮件是否被其他用户使用相比。对于花名册,如果在花名册表中找不到,我们将提出错误。你知道吗
注意:确保将您的花名册模型导入到您添加支票的任何位置。你知道吗
相关问题 更多 >
编程相关推荐