#serializers.py
import os
from ... import settings #app name
class FilesSerializer(serializers.ModelSerializer):
file_size = serializers.SerializerMethodField()
class Meta:
model = File
fields = ['id', 'name', 'file', 'file_size', 'catalog_item']
def get_file_size(self, obj):
return os.path.getsize(settings.BASE_DIR + obj.file.url)
$arResult["DETAIL_TEXT"] = str_ireplace( '<img ', '<img alt="..."', $arResult["DETAIL_TEXT"] );