In a Django project, I have models defined like this :
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contri
I've found a workaround filtering File's object with the appropriate content_type_id and object_id:
from django.contrib.contenttypes.models import ContentType
# ...
folder_contenttype = ContentType.objects.get(name="folder")
for folder in orm.Folder.objects.all():
for f in orm.File.objects.filter(content_type_id = folder_contenttype.id, object_id = folder.id): # replaces folder.files.iterator():
# ...
This works but is less readable.