考虑到用户可以在浏览器中禁用JavaScript,我该如何在 Django 后端进行“双重检查”以进行电子邮件验证(具体来说,是为了防止使用Webmail [GMail注册] ,Hotmail等])?谢谢。
答案 0 :(得分:0)
您可以在您的forms.py(必须创建该文件)应用中执行此操作
from django import forms
class ContactForm(forms.Form):
full_name = forms.CharField()
email = forms.EmailField()
def clean_email(self, *args, **kwargs):
email = self.cleaned_data.get('email')
if email.endswith('@gmail.com'): # etc.
raise forms.ValidationError('This is not a valid email')
return email