0
如何循環遍歷QuerySet
的所有字段。我需要將所有字段值的列表導出到xlsx文件,但不能使用client.name
來預定義列。遍歷模型列
如果循環對象,我剛拿到ID:
for i in Model.objects.all():
print i
如果我試圖巢循環,我得到TypeError 'Model' object is not iterable
。如果導出爲CSV/XLSX
for i in Model.objects.all():
for y in i:
print y