Closed Klurifixus closed 10 months ago
add : def clean_text(self): text = self.cleaned_data['text']
if 'badword' in text:
raise forms.ValidationError("Inappropriate content detected.")
return text
BAD_WORDS = [ 'badword1', 'badword2', 'inappropriate', 'offensive phrase',
def clean_text(self): text = self.cleaned_data['text']
# Check if any bad words are present
for bad_word in BAD_WORDS:
if bad_word in text:
raise forms.ValidationError("Inappropriate content detected.")
return text
in forms.py
Ensure that user inputs, especially in forms like the comment form, are properly validated and sanitized to prevent security issues like SQL injection or XSS attacks.