DJANGO: How to Output CSV with model containing many-to-many field?

梦想的初衷 提交于 2019-12-06 14:58:50

Depends on what field you want to print in the features model... You are looking at an m2m manager - it's a helper that returns a queryset interface. If you want all related features, you'd want to call x.features.all()

Replace with your actual field on the features model.

csv_features = ','.join([x.MY_FIELD_HERE for x in x.features.all()])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!