shadow_mso

Untitled

Aug 4th, 2020
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. class paymentInvoiceSerializer(serializers.ModelSerializer):
  2.     invoiceOwner = purchaserSerializer(many=False)
  3.     class Meta:
  4.         model = paymentInvoice
  5.         fields = '__all__'
  6.  
  7.  
  8.     def create(self, validated_data):
  9.  
  10.         purchaser_data = {"name": validated_data.pop("invoiceOwner")}
  11.         purchaser = Purchaser.objects.create(**purchaser_data)
  12.         validated_data.update({"invoiceOwner": purchaser})
  13.  
  14.         return paymentInvoice.objects.create(**validated_data)
Advertisement
Add Comment
Please, Sign In to add comment