def METHOD_NAME(self):
    photo_upload = self.cleaned_data['photo_upload']
    if photo_upload:
        extension = splitext(photo_upload.name)[1]
        # check the extension
        if extension.lower() not in ALLOWED_LOGO_EXT:
            raise forms.ValidationError('The photo must be of jpg, gif, or png image type.')
        # check the image header
        image_type = '.%s' % imghdr.what('', photo_upload.read())
        if image_type not in ALLOWED_LOGO_EXT:
            raise forms.ValidationError('The photo is an invalid image. Try uploading another photo.')
    return photo_upload