Horje
drf serializer general validate method Code Example
drf serializer general validate method
from rest_framework import serializers

class EventSerializer(serializers.Serializer):
    description = serializers.CharField(max_length=100)
    start = serializers.DateTimeField()
    finish = serializers.DateTimeField()

    def validate(self, attrs):
        """
        Check that the start is before the stop.
        """
        if attrs['start'] > attrs['finish']:
            raise serializers.ValidationError("finish must occur after start")
        return attrs




Python

Related
h==gmail Code Example h==gmail Code Example
python string and variable in 1 print Code Example python string and variable in 1 print Code Example
django rest framework foreign key relation giving error in serializer Code Example django rest framework foreign key relation giving error in serializer Code Example
fibonacci series python using function Code Example fibonacci series python using function Code Example
duplicate a list with for loop in python Code Example duplicate a list with for loop in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7