Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Add a clean-method to check the desired field to the form class :
STOP_LIST = [
'мат',
'мат',
'мат',
]
class ContactForm(forms.Form):
...
def clean_text(self):
text = self.cleaned_data['text']
for word in STOP_LIST:
if word in text:
raise forms.ValidationError("Вы позволили себе немного лишнего! Одумайтесь и исправьте текст!")
return text
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question