yangi api qoshildi
This commit is contained in:
24
core/apps/shared/serializers/dis_product.py
Normal file
24
core/apps/shared/serializers/dis_product.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# rest framework
|
||||
from rest_framework import serializers
|
||||
|
||||
# orders
|
||||
from core.apps.orders.models import DistributedProduct
|
||||
|
||||
|
||||
class DistributedProductListSerializer(serializers.ModelSerializer):
|
||||
product = serializers.SerializerMethodField(method_name='get_product')
|
||||
|
||||
class Meta:
|
||||
model = DistributedProduct
|
||||
fields = [
|
||||
'id', 'product', 'quantity', 'employee_name', 'quantity', 'created_at'
|
||||
]
|
||||
ref_name = "DisProductListSerializer"
|
||||
|
||||
def get_product(self, obj):
|
||||
return {
|
||||
"id": obj.product.id,
|
||||
"name": obj.product.name,
|
||||
"price": obj.product.price,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user