Hi, You will need to loop on the items and use a serializer on each of them.
Regards, Xavier Ordoquy, Linovia. > Le 14 mai 2017 à 07:19, Gaurav Pant <[email protected]> a écrit : > > > 0 > down vote > <>favorite > > <http://stackoverflow.com/questions/43960378/django-rest-framework-nested-serializer-retrieve-valid-records-of-nested-ser#> > > I am retrieving multiple client records at a time using > "RegistrationSystemSerializer" serialize here. > > class ClientRecordSerializer(serializers.Serializer): > client_id = serializers.IntegerField() > date_of_birth = serializers.DateField() > > class RegistrationSystemSerializer(serializers.Serializer): > count = serializers.IntegerField() > results = ClientRecordSerializer(many=True) > If anytime anyone of client records is invalid then it is aborting entire > process of extraction. i.e. suppose I have data like > > { > "count" : 4, > "results":[ > { > "client_id":"1234", > "date_of_birth":"2012-02-06" > }, > { > "client_id":"2345", > "date_of_birth":"2013-02-06" > }, > { > "client_id":"4567", > "date_of_birth":"2014-02-06" > }, > { > "client_id":"1239", > "date_of_birth":"06-02-2017" # invalid date format > }, > ] > } > where "date_of_birth" of 4th client is in wrong format because a valid date > can be only in "YYYY-MM-DD" format. If I apply above serialize in this data > then it will not give me any data because one of the nested record do not > satisfy criteria. What I want is to get all three valid nested records from > serialize but error for the fourth one. > > How to achieve the same using Django rest framework. > > > > -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
