[Answered ]-Include text and variable in ValidationError

1👍

You can use string formatting to include the text of the image in a string, for example:

def validate_image(image):
    file_size = image.file.size
    if file_size > settings.MAX_UPLOAD_SIZE:
        raise ValidationError(f'Image {image} is too large')

Leave a comment