16 lines
439 B
Python
16 lines
439 B
Python
"""Serializer mixins"""
|
|
from rest_framework import serializers
|
|
|
|
|
|
class ImageSerializerMixin(serializers.Serializer):
|
|
"""
|
|
Image serializer mixin.
|
|
Need to return an absolute path of cropped image instead of relative path
|
|
"""
|
|
# RESPONSE
|
|
image = serializers.SerializerMethodField()
|
|
|
|
def get_image(self, obj):
|
|
"""Get full image URL"""
|
|
return obj.image.get_full_image_url(self.context.get('request'))
|