Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

PREVIOUS NEXT
Code Example
Python :: print output 
Python :: pandas split column into multiple columns 
Python :: PyPip pygame 
Python :: from django.core.management import execute_from_command_line ImportError: No module named django.core.management 
Python :: while true loop python 
Python :: flask rest api upload image 
Python :: pandas if value present in df index 
Python :: python program to check whether a number is even or odd 
Python :: quantile-quantile plot python 
Python :: check space in string python 
Python :: pyspark dataframe to dictionary 
Python :: open image in PILLOW 
Python :: CACHE_TYPE flask 
Python :: class inside class python 
Python :: how to set python path in mac 
Python :: print all variables jupyter notebook 
Python :: add a column with initial value to an existing dataframe 
Python :: Progress Bars in Python 
Python :: python django query 
Python :: create python dataframe 
Python :: faker, generates fake data for you 
Python :: python get audio from video 
Python :: python print variable 
Python :: how delete element from list python 
Python :: gevent with flask 
Python :: Adding new column to existing DataFrame in Pandas using assign method 
Python :: python library to convert decimal into octal and hexadecimal 
Python :: python button tkinter change color 
Python :: python read from stdin pipe 
Python :: print on same line 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =