blob: 68acfeebcb974be036f294ad69aa16d96b2d771a (
plain) (
tree)
|
|
from django import forms
from django_recaptcha.fields import ReCaptchaField
from django_recaptcha.widgets import ReCaptchaV2Checkbox
from .models import EmailVerification
class EmailVerificationForm(forms.ModelForm):
captcha = ReCaptchaField(widget=ReCaptchaV2Checkbox)
class Meta:
model = EmailVerification
fields = ["email"]
def clean_email(self):
email = self.cleaned_data.get("email")
if EmailVerification.objects.filter(email=email).exists():
raise forms.ValidationError("This email address is already in use.")
return email
|