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.
1. Install the package
Section titled “1. Install the package”pip install easy-thumbnails-restThat’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.
2. Confirm your prerequisites
Section titled “2. Confirm your prerequisites”The fields read your existing easy-thumbnails configuration, so a few things from that library need to be in place first:
-
easy_thumbnailsis inINSTALLED_APPS:INSTALLED_APPS = [# ...'easy_thumbnails',] -
Your image fields use easy-thumbnails’
ThumbnailerImageFieldinstead of Django’s plainImageField:from django.db import modelsfrom easy_thumbnails.fields import ThumbnailerImageFieldclass Profile(models.Model):image = ThumbnailerImageField(upload_to='photos') -
THUMBNAIL_ALIASESis defined insettings.pywith 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.
3. Import the fields
Section titled “3. Import the fields”The three fields live in easy_thumbnails_rest.serializers:
from easy_thumbnails_rest.serializers import ( ThumbnailerSerializer, ThumbnailerListSerializer, ThumbnailerJSONSerializer,)Next steps
Section titled “Next steps”- Usage — wire the fields into a serializer and see what each one returns.
- Configuration — how
THUMBNAIL_ALIASEStargets and aliases map to each field.