Paste #27
1 2 3 4 5 6 7 8 9 | from kay.utils import forms from kay.utils.validators import ValidationError class ImageField(forms.FileField): allowed_content_types = ('image/jpeg', 'image/png', 'image/gif') def convert(self, value): if value.content_type not in self.allowed_content_types: raise ValidationError("Invalid file type for cover.") return super(ImageField, self).convert(value) |