diff --git a/apiserver/apiserver/api/utils.py b/apiserver/apiserver/api/utils.py index c0f0a1c..c3ce89d 100644 --- a/apiserver/apiserver/api/utils.py +++ b/apiserver/apiserver/api/utils.py @@ -11,7 +11,7 @@ from rest_framework.views import exception_handler from dateutil import relativedelta from uuid import uuid4 from PIL import Image, ImageDraw, ImageFont, ImageOps, JpegImagePlugin -#JpegImagePlugin._getmp = lambda x: None +JpegImagePlugin._getmp = lambda x: None from bleach.sanitizer import Cleaner from PyPDF2 import PdfFileWriter, PdfFileReader from reportlab.pdfgen import canvas @@ -180,7 +180,7 @@ def process_image_upload(upload, crop): try: pic = Image.open(upload) except OSError: - raise serializers.ValidationError(dict(photo='Invalid image file.')) + raise serializers.ValidationError(dict(non_field_errors='Invalid image file.')) logging.info('Detected format: %s', pic.format) @@ -189,7 +189,7 @@ def process_image_upload(upload, crop): elif pic.format == 'JPEG': ext = '.jpg' else: - raise serializers.ValidationError(dict(photo='Image must be a jpg or png.')) + raise serializers.ValidationError(dict(non_field_errors='Image must be a jpg or png.')) pic = ImageOps.exif_transpose(pic)