I have a django app and I want to expose the model images, such that when I request /image/school_id/400
it will return the image of school with id school_id
cropped and resized to a box 400x400 px. Here is what I tried
@api_view(['GET', 'POST'])
def image_view(request, school_id, size):
image = School.objects.get(school__pk=school_id).image
resized_img = image #Handle resizing here
return Response(resized_img, content_type='*/*')
and all am getting is an error 'utf8' codec can't decode byte 0xff in position 0: invalid start byte
How do i return the image? Am using Django-rest-framework http://www.django-rest-framework.org/api-guide/renderers#advanced-renderer-usage