What does .only django queryset really do?
<p>I heard in the Django documentation it optimizes so I did a little bit of experimentation. So I did this:</p>

<pre><code>&gt;&gt;&gt; x = Artist.objects.only('id').filter()
&gt;&gt;&gt; print x.query
SELECT "store_artist"."id" FROM "store_artist"

&gt;&gt;&gt; y = Artist.objects.filter()
&gt;&gt;&gt; print y.query
SELECT "store_artist"."id", "store_artist"."name", "store_artist"."birth_date" FROM "store_artist"
</code></pre>

<p>I can see that the query changed however I did a further test:</p>

<pre><code>&gt;&gt;&gt; for _x in x:
    ... _x.name
    ... 
    u'Beyone'
    u'Beyoneeee'
    u'Beyone231231'
    u'Beyone2222'
    u'No Album'

&gt;&gt;&gt; for _y in y: 
    ...  _y.name
    ...
    u'Beyone'
    u'Beyoneeee'
    u'Beyone231231'
    u'Beyone2222'
    u'No Album'
</code></pre>

<p>So if you've noticed it just has the same result. How did that happen? I thought that in the <em>y</em> variable I just fetched the id so the name should not appear or be invalid</p>

<p>Here is my model by the way:</p>

<pre><code>class Artist(EsIndexable, models.Model):
    name = models.CharField(max_length=50)
    birth_date = models.DateField()
</code></pre>

<p>It does only query the fields you give it, but then it still returns instances of that model. So when you ask for a different field, you would have made a second query to get the name</p>

python django