データベースからデータを取得し、次のように見えるPythonのコードがあります。
for result in request.user.results.all():
data.append(dict([(str(word.type.type), str(word.word)) for word in result.word.all()
data.append(dict([(season, ResultForm.CHOICES[r.season][1])]))
'data'を次のように表示します。
[{'color': 'blue', 'kind': 'pencil', 'rating': 'high'}, {'color': 'red', 'kind': 'truck', 'rating': 'low'}, {'season': 'winter'}, {'season': 'spring'}]
データの出力が次のようになるようにコードを調整するにはどうすればよいですか?
[{'color': 'blue', 'kind': 'pencil', 'rating': 'high', 'season': 'winter'}, {'color': 'red', 'kind': 'truck', 'rating': 'low', 'season': 'spring'}]
最後のオブジェクトを追加するだけでなく、各要素に追加します。