From 1163d64c0657728592ac131a6c639af99811ba1c Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 12 Nov 2023 22:08:34 +0800 Subject: [PATCH] Add equipment field to equipment instance log serializer to correctly identify equipment when viewing logs --- equipment_tracker/equipments/serializers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/equipment_tracker/equipments/serializers.py b/equipment_tracker/equipments/serializers.py index 1efd779..8858be0 100644 --- a/equipment_tracker/equipments/serializers.py +++ b/equipment_tracker/equipments/serializers.py @@ -116,12 +116,14 @@ class EquipmentInstanceLogsSerializer(serializers.HyperlinkedModelSerializer): history_date = serializers.DateTimeField( format="%m-%d-%Y %I:%M%p", read_only=True) history_user = serializers.SerializerMethodField() + equipment = serializers.PrimaryKeyRelatedField( + source='equipment.name', queryset=Equipment.objects.all()) class Meta: model = EquipmentInstance.history.model - fields = ('history_id', 'status', 'remarks', + fields = ('history_id', 'id', 'equipment', 'status', 'remarks', 'history_date', 'history_user') - read_only_fields = ('history_id', 'id', 'status', 'remarks', + read_only_fields = ('history_id', 'id', 'equipment', 'status', 'remarks', 'history_date', 'history_user') def get_history_user(self, obj):