Skip to content

Commit

Permalink
Fixes 'RelatedManager' object is not iterable in ListSerializer.to_re…
Browse files Browse the repository at this point in the history
…presentation.(#8726)
  • Loading branch information
954-Ivory committed Oct 24, 2022
1 parent 5b616c5 commit e52d4e8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rest_framework/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,9 @@ def to_representation(self, data):
"""
# Dealing with nested relationships, data can be a Manager,
# so, first get a queryset from the Manager if needed
iterable = data.all() if isinstance(data, models.Manager) else data
iterable = data.all() if isinstance(data, (
models.manager.Manager, models.manager.BaseManager
)) else data

return [
self.child.to_representation(item) for item in iterable
Expand Down

0 comments on commit e52d4e8

Please sign in to comment.