easy-thumbnails

Django easy-thumbnails serialize with Django Rest Framework

醉酒当歌 提交于 2021-01-29 17:55:03
问题 The docs on their GitHub page suggests that what I'm trying to do should work: thumb_url = profile.photo['avatar'].url In my project, it gives an error: THUMBNAIL_ALIASES = { '': { 'thumb': {'size': (64, 64), 'upscale': False}, }, } class Image(models.Model): place = models.ForeignKey(Place, models.CASCADE, 'images') image = ThumbnailerImageField(upload_to='') class ImageSerializer(serializers.Serializer): image = serializers.ImageField() thumb = serializers.ImageField(source='image.image[

Django Rest Framework with easy-thumbnails

家住魔仙堡 提交于 2021-01-26 14:47:10
问题 With a normal ImageField, serializing the URL is simply image = serializers.ImageField() . What should it look like when using easy-thumbnails? So far, I've only found a function for getting the URL: Django easy_thumbnails accessing image URLs Using this in a serializer would require a SerializerMethodField, which is an unsatisfying solution. I'm looking for a solution that's as efficient/performant as practical, and on one line. 回答1: Best solution is probably to subclass serializers

Django Rest Framework with easy-thumbnails

孤街醉人 提交于 2021-01-26 14:46:21
问题 With a normal ImageField, serializing the URL is simply image = serializers.ImageField() . What should it look like when using easy-thumbnails? So far, I've only found a function for getting the URL: Django easy_thumbnails accessing image URLs Using this in a serializer would require a SerializerMethodField, which is an unsatisfying solution. I'm looking for a solution that's as efficient/performant as practical, and on one line. 回答1: Best solution is probably to subclass serializers

Django easy_thumbnails accessing image URLs

↘锁芯ラ 提交于 2020-01-23 09:56:32
问题 Is it possible to access the URLs of easy_thumbs created images? I have a model with an ImageField and a ModelForm to match. # models.py class ModelWithAnImage(models.Model): image = ThumbnailerImageField( upload_to='images', ) Following the documentation I am using signals to generate two thumbs when the image is uploaded. # somewherethatdefinitelygetsloaded.py from easy_thumbnails.signals import saved_file from easy_thumbnails.signal_handlers import generate_aliases_global saved_file

Django easy_thumbnails accessing image URLs

一笑奈何 提交于 2020-01-23 09:56:16
问题 Is it possible to access the URLs of easy_thumbs created images? I have a model with an ImageField and a ModelForm to match. # models.py class ModelWithAnImage(models.Model): image = ThumbnailerImageField( upload_to='images', ) Following the documentation I am using signals to generate two thumbs when the image is uploaded. # somewherethatdefinitelygetsloaded.py from easy_thumbnails.signals import saved_file from easy_thumbnails.signal_handlers import generate_aliases_global saved_file

Easy Thumbnail with Django raising access denied error

雨燕双飞 提交于 2020-01-05 03:45:11
问题 I'm using S3Boto3Storage to save docs in my aws s3 and tried to use easy-thumbnails to generate thumbnail images, please find the code below Model class class ThumbnailTestModel(models.Model): sample1 = models.FileField( storage=S3Boto3Storage(), help_text="Field to store the sample document of Professional", null=True, blank=True, upload_to=s3_professional_sample_storage_path) sample1_file_name = models.CharField(blank=True,null=True,max_length=1000, default=True) View class class

Django easy_thumbnails accessing image URLs

烂漫一生 提交于 2019-12-05 21:02:23
Is it possible to access the URLs of easy_thumbs created images? I have a model with an ImageField and a ModelForm to match. # models.py class ModelWithAnImage(models.Model): image = ThumbnailerImageField( upload_to='images', ) Following the documentation I am using signals to generate two thumbs when the image is uploaded. # somewherethatdefinitelygetsloaded.py from easy_thumbnails.signals import saved_file from easy_thumbnails.signal_handlers import generate_aliases_global saved_file.connect(generate_aliases_global) This is working fine but is it possible to then access the url for those