bizcochito.onion/webpage/forms.py

15 lines
623 B
Python
Raw Normal View History

2023-06-22 08:27:56 +00:00
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as txt
class SignbookForm(forms.Form):
name = forms.CharField(label="Name")
website = forms.CharField(label="Website", required=False)
email = forms.EmailField(label="Email", required=False)
comment = forms.CharField(label="Comment", required=False)
capcha = forms.CharField(label="Tell me that you love 'me'")
def validate_capcha(self):
if self.cleaned_data["capcha"].lower() != "i love me":
raise ValidationError(txt('Invalid captcha'))
return self