[Django]-TypeError: ManyRelatedManager object is not iterable

46👍

An m2m field is returned as a related manager object so its not iterable. You need to use all to convert it to a queryset to make it iterable.

if tbl_scope == 'Generic':
        checked_objects = A.objects.get(user=user, project=project)


 for checked_object in checked_objects.definitions.all():
        print(checked_object.indicator)

You can read more about m2m field.

Leave a comment