Django GenericRelation fields not available during South migration

好久不见. 提交于 2019-12-02 01:35:48

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!