From a70d451ca188be3a4b1fe4ce046be0a3584b9837 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Mon, 14 Jul 2025 14:12:34 +0330 Subject: [PATCH] livestock type in age limitations --- .../web/api/v1/serializers/quota_serializers.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/product/web/api/v1/serializers/quota_serializers.py b/apps/product/web/api/v1/serializers/quota_serializers.py index 017ab43..07e1c02 100644 --- a/apps/product/web/api/v1/serializers/quota_serializers.py +++ b/apps/product/web/api/v1/serializers/quota_serializers.py @@ -149,6 +149,17 @@ class QuotaLiveStockAgeLimitationSerializer(serializers.ModelSerializer): model = product_models.QuotaLiveStockAgeLimitation fields = '__all__' + def to_representation(self, instance): + """ custom output for livestock type """ + + representation = super().to_representation(instance) + if isinstance(instance, product_models.QuotaLiveStockAgeLimitation): + representation['livestock_type'] = LiveStockTypeSerializer( + instance.livestock_type + ).data + + return representation + def update(self, instance, validated_data): """ Custom Update """