Allow `ListSerializer` to parse partial good results and ignore bad ones
See original GitHub issueWhat is your use-case and why do you need this feature?
I’m receiving a list of items from the server. Some of the items might miss some required fields or be otherwise malformed.
In this case, I would like to ignore the items that failed to parse but still parse the ones that I can.
Unfortunately, it looks like ListSerializer
is failing as soon as it encounters a single list item which it fails to parse.
Describe the solution you’d like
Some sort of ignoreFailedListItems
or allowPartialListResults
configuration.
*This probably applies to all collections.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Serializers - Django REST framework
Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily ...
Read more >unable to update existing data using Django Rest Framework?
BytesIO(json_data) data = JSONParser().parse(stream) serializer = CustomersSerializer(data=data) if serializer.is_valid(): temp_dict = ...
Read more >3.0 Announcement - Django REST framework
Printable representations on serializers that allow you to inspect exactly what fields are present on the instance. Simple model serializers that are vastly ......
Read more >tf.distribute.MultiWorkerMirroredStrategy | TensorFlow v2.11.0
If you are interested in last partial batch handling, read this section. ... one input file per worker, we suggest that you disable...
Read more >drf-yasg Documentation - Read the Docs
ing the specified UI renderer; one of swagger, redoc ... Enable/disable Django login as an authentication/authorization mechanism.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A serializer for a type with generic parameter will need a constructor that takes a serializer for that generic parameter. In this case you want to use
@SerializeWith(KindListSerializer::class)
, you don’t need to create a subclass for the parameter type (that will actually not work as you found).It looks like the error is imprecise. If your
CustomDataSerializer
is a serializer forList
, it should be applied to the List, not to its generic type arg:val data: @Serializable(CustomDataSerializer::class) List<Data>