Skip to content

Installation

Getting Easy Thumbnails REST running takes one install plus a quick check that your easy-thumbnails setup is in place. The package depends on django, djangorestframework, and easy-thumbnails, so pip pulls those in for you if they aren’t already installed.

Terminal window
pip install easy-thumbnails-rest

That’s the only install step. There’s no app to add to INSTALLED_APPS for this package itself — it just provides serializer fields you import and use.

The fields read your existing easy-thumbnails configuration, so a few things from that library need to be in place first:

  • easy_thumbnails is in INSTALLED_APPS:

    INSTALLED_APPS = [
    # ...
    'easy_thumbnails',
    ]
  • Your image fields use easy-thumbnails’ ThumbnailerImageField instead of Django’s plain ImageField:

    from django.db import models
    from easy_thumbnails.fields import ThumbnailerImageField
    class Profile(models.Model):
    image = ThumbnailerImageField(upload_to='photos')
  • THUMBNAIL_ALIASES is defined in settings.py with at least one alias:

    THUMBNAIL_ALIASES = {
    '': {
    'avatar': {'size': (50, 50), 'crop': True},
    },
    }

    If you haven’t set this up yet, see the easy-thumbnails thumbnail aliases docs for the full structure.

The three fields live in easy_thumbnails_rest.serializers:

from easy_thumbnails_rest.serializers import (
ThumbnailerSerializer,
ThumbnailerListSerializer,
ThumbnailerJSONSerializer,
)
  • Usage — wire the fields into a serializer and see what each one returns.
  • Configuration — how THUMBNAIL_ALIASES targets and aliases map to each field.