Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

def create(self validated_data)

class UserSerializer(serializers.ModelSerializer):

    def create(self, validated_data):
        customer_serializer = CustomerSerializer(validated_data.get('customer'))
        customer_serializer.save()
        return User.objects.create(**validated_data)

    class Meta:
        model = User
        fields = '__all__'
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #def
ADD COMMENT
Topic
Name
4+3 =