“Def create (self validated_data)” Code-Antworten

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__'
Clear Curlew

User Serializer im Django REST -Framework

class Event(models.Model):
    user = models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    date = models.DateTimeField(default=timezone.now)
    place = models.CharField(max_length=255)
Confused Cormorant

Ähnliche Antworten wie “Def create (self validated_data)”

Fragen ähnlich wie “Def create (self validated_data)”

Weitere verwandte Antworten zu “Def create (self validated_data)” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen