擅长:python、mysql、java
<p>如果您只需要一个<code>choice_text</code>的平面列表,那么可以将<code>.values_list()</code>与<code>flat=True</code>参数一起使用。例如:</p>
<pre><code>correct_answer = Choice.objects.filter(question=i, answer=True).values_list('choice_text', flat=True)
# correct_answer will be ['yes', 'no'] or whatever the choice_text's are.
</code></pre>
<p>这是关于<code>.values_list()</code>:<a href="https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list" rel="nofollow">https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list</a>的文档</p>