Easy Thumbnails Rest
Easy Thumbnails Fields for Django Rest API Framework
Installation
pip install easy-thumbnails-rest
Tested on Django 2.2, 3.1, 3.2
Usage
This package is an extension for easy-thumbnails.
Please make sure to have THUMBNAIL_ALIASES defined in settings.py.
If not added, please check Easy Thumbnails Docs to add it.
To use the serializer fields provided by this package you need to have your image fields defined as provided here: easy-thumbnails fields
Example settings.THUMBNAIL_ALIASES
THUMBNAIL_ALIASES = {
'': {
'avatar': {'size': (50, 50), 'crop': True},
},
}
Fields
- ThumbnailerSerializer
- ThumbnailerListSerializer
- ThumbnailerJSONSerializer
ThumbnailerSerializer
You can use ThumbnailerSerializer to get image's predefined alias. You need to pass argument alias with value as one of the aliases name defined in THUMBNAIL_ALIASES
Example:
from rest_framework import serializers
from easy_thumbnails_rest.serializers import ThumbnailerSerializer
class ExampleSerializer(serializers.ModelSerializer):
image = ThumbnailerSerializer(alias='avatar')
class Meta:
model = ExampleModel
fields = '__all__'
From the above example the field image will contain string value of alias image url.
ThumbnailerListSerializer
You can use ThumbnailerListSerializer to get image's predefined alias image list. You need to pass argument alias with value as one of the target's in THUMBNAIL_ALIASES.
If you don't understand where to find target, please see the structure of the THUMBNAIL_ALIASES in Easy Thumbnails Docs
Example:
from rest_framework import serializers
from easy_thumbnails_rest.serializers import ThumbnailerListSerializer
class ExampleSerializer(serializers.ModelSerializer):
image = ThumbnailerListSerializer(alias='target')
class Meta:
model = ExampleModel
fields = '__all__'
From the above example the field image will contain list of all aliased image urls under the given target.
ThumbnailerJSONSerializer
You can use ThumbnailerJSONSerializer to get image's predefined alias image list. You need to pass argument alias with value as one of the target's in THUMBNAIL_ALIASES.
If you don't understand where to find target, please see the structure of the THUMBNAIL_ALIASES in Easy Thumbnails Docs
Example:
from rest_framework import serializers
from easy_thumbnails_rest.serializers import ThumbnailerJSONSerializer
class ExampleSerializer(serializers.ModelSerializer):
image = ThumbnailerJSONSerializer(alias='target')
class Meta:
model = ExampleModel
fields = '__all__'
From the above example the field image will contain list of key-value pair where key's are the alias under the given target and values are the respective image url.
Metadata
Release files for easy-thumbnails-rest 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| easy-thumbnails-rest-1.1.4.tar.gz | 4.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easy_thumbnails_rest-1.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / easy-thumbnails-rest-1.1.4.tar.gz
| Download URL | easy-thumbnails-rest-1.1.4.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1c619e812c57a85932f1f3b061667bc4b9002528056d5d8fa4c99e4c567385a
|
|
BLAKE2b-256 checksum How to use checksums |
83de13e812ecede45b44f0ca3383e49e72dcf7a98ad095603f94a67e22e151c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
|
Release files / easy_thumbnails_rest-1.1.4-py3-none-any.whl
| Download URL | easy_thumbnails_rest-1.1.4-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22d2789bb3f9a26d949e7f292a23f02a5feb68ef8badcb53bac1fd1466322d60
|
|
BLAKE2b-256 checksum How to use checksums |
b2ecc390f9e58e0924ae575abf7483fcb9be93fedf97130759e0b8314f4aad2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
|
Security for easy-thumbnails-rest 1.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.