An image serializer field for use with sorl and Django REST Framework.
Provides an easy way of exposing a scaled version of an image rather than the full-size one, and if you prefer several different versions (thumb, large etc.)
Installation
PyPI
pip install sorl-thumbnail-serializer-field
Github
pip install -e git+git@github.com:dessibelle/sorl-thumbnail-serializer-field.git@master#egg=sorl_thumbnail_serializer
Quick start
Add 'sorl_thumbnail_serializer' to the list of installed applications in your project’s settings.py file. Make sure you have already installed and configured sorl-thumbnail and Django REST Framework as well, if not do so now.
Add the HyperlinkedSorlImageField to your serializer class.
Specify the image dimensions and cropping options that the REST API should use.
Example usage
# urls.py
from django.conf.urls import url, include
from models import TestModel
from rest_framework import routers, serializers, viewsets
from sorl_thumbnail_serializer.fields import HyperlinkedSorlImageField
class TestModelSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = TestModel
# A thumbnail image, sorl options and read-only
thumbnail = HyperlinkedSorlImageField(
'128x128',
options={"crop": "center"},
source='image',
read_only=True
)
# A larger version of the image, allows writing
image = HyperlinkedSorlImageField('1024')
class TestModelViewSet(viewsets.ModelViewSet):
queryset = TestModel.objects.all()
serializer_class = TestModelSerializer
router = routers.DefaultRouter()
router.register(r'test_models', TestModelViewSet)
urlpatterns = [
url(r'^', include(router.urls)),
]
Metadata
Release files for sorl-thumbnail-serializer-field 0.2.1
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 | |
|---|---|---|---|---|
| sorl-thumbnail-serializer-field-0.2.1.tar.gz | 8.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sorl_thumbnail_serializer_field-0.2.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 22.1 kB
Release files / sorl-thumbnail-serializer-field-0.2.1.tar.gz
| Download URL | sorl-thumbnail-serializer-field-0.2.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
905a05a81e83bceb9c49392010802981a7d8100478cc67ef4acfb53beb1ab505
|
|
BLAKE2b-256 checksum How to use checksums |
75e601bc43a5ee53d5ebcd4a60deeeb564c5671c61c83f7e9b439b1a33de6758
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / sorl_thumbnail_serializer_field-0.2.1-py2.py3-none-any.whl
| Download URL | sorl_thumbnail_serializer_field-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6f4adb757d798c3cd556668333c83dc17926dd6bea420dff293fb35ec170e03e
|
|
BLAKE2b-256 checksum How to use checksums |
fdd09a5a2f55e9d25f3733bb7efbe051e3b13c12e99ad5a3b7d171448e0f6690
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for sorl-thumbnail-serializer-field 0.2.1
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.