'RelatedManager' object is not iterable · Issue #8726 · encode/django-rest-framework (original) (raw)
These days, I create a custom manager repr for django:
https://github.com/954-Ivory/django_bulk_hook_manager
But I get the error when I use it with DRF:
rest_framework/serializers.py", line 686, in to_representation return [ TypeError: 'RelatedManager' object is not iterable
So, I check it, and found the reason.
iterable = data.all() if isinstance(data, models.Manager) else data
This line should change to:
iterable = data.all() if isinstance(data, ( models.manager.Manager, models.manager.BaseManager )) else data
We need to check whether data
is a BaseManager
instance.
I will PR later.