diff --git a/news/forms.py b/news/forms.py index 895aa57..02ded06 100644 --- a/news/forms.py +++ b/news/forms.py @@ -7,6 +7,7 @@ from os.path import join from PIL import Image import os from amadeus import settings +from django.utils.html import strip_tags class NewsForm(forms.ModelForm): MAX_UPLOAD_SIZE = 5*1024*1024 @@ -78,3 +79,13 @@ class NewsForm(forms.ModelForm): return ValueError return image + def clean_content(self): + content = self.cleaned_data.get('content', '') + cleaned_content = strip_tags(content) + + if cleaned_content == '': + self._errors['content'] = [_('This field is required.')] + + return ValueError + + return content -- libgit2 0.21.2