3

I've got the following setup:

#models.py
class Image(models.Model):
    original = models.ImageField(upload_to='images/')
    formatted_image = ImageSpecField(source='original', format='JPEG', options={'quality': 90})


#serializers.py
class ImageSerializer(serializers.ModelSerializer):
    class Meta:
        model = Image

#views.py
class ImageViewSet(viewsets.ModelViewSet):
    model = Image
    serializer_class = ImageSerializer

According to the ImageKit documentation this should do the trick but literally nothing happens. Not even an error or anything. What am I doing wrong?

matteok
  • 2,189
  • 3
  • 30
  • 54
  • "Nothing happens" is rather vague. Is it for instance uploading or viewing images that doesn't work? – Joar Leth Jul 31 '14 at 14:03
  • I meet the same question, and open an issue to django-imagekit:https://github.com/matthewwithanm/django-imagekit/issues/289 – the5fire Aug 06 '14 at 02:14
  • @Joar Leth: By nothing happens I mean literally nothing. No file is being created, no error is being thrown, nothing shows up in the database and to the serializer the fields don't exist. – matteok Aug 06 '14 at 10:37
  • @the5fire: thanks for doing that – matteok Aug 06 '14 at 10:37
  • @matteok Hi! I am having the same problem. What was your solution? – Kakar Feb 28 '17 at 18:33
  • Can you try adding processors=[Transpose(),ResizeToFit(50,50)] as a parameter to the ImageSpecField? Hope that does the trick – matteok Feb 28 '17 at 19:20

1 Answers1

1
#serializers.py
class ImageSerializer(serializers.ModelSerializer):
    formatted_image = serializers.ImageField()
    class Meta:
        model = Image

This worked for me.

Toon
  • 101
  • 2
  • 9