Files
eggs-backend/core/apps/eggs/serializers/history.py
husanjon ab73d05ecc
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
gold eggs backend
2026-04-15 08:59:36 +02:00

27 lines
634 B
Python

from rest_framework import serializers
from core.apps.eggs.models import History
class HistorySerializer(serializers.ModelSerializer):
avatar = serializers.SerializerMethodField()
class Meta:
model = History
fields = [
"id",
"content_type",
"object_id",
"action",
"avatar",
"timestamp",
"created_by",
"created_who",
"comment",
"reason",
]
def get_avatar(self, obj):
if obj.avatar and hasattr(obj.avatar, "url"):
return obj.avatar.url
return None