Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
27 lines
634 B
Python
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
|