serializers.py 568 B

12345678910111213141516171819202122
  1. from rest_framework import serializers
  2. from .models import Order,OrderGood
  3. from goods.serializers import GoodSerializer
  4. class OrderGoodSertializer(serializers.ModelSerializer):
  5. good = GoodSerializer()
  6. class Meta:
  7. model = OrderGood
  8. fields = ['_id',"price","count","good",]
  9. class OrderSerializer(serializers.ModelSerializer):
  10. orderGoods = OrderGoodSertializer(many=True)
  11. class Meta:
  12. model = Order
  13. fields = ['_id',"date","price","status","orderGoods","phoneNumber","email","name","surname","address","delivery"]