How to print the query of .get queryset in django
<p>How can I know the query when doing a .get queryset in django</p>

<p>I have this model:</p>

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

<p>And I did this in the shell:</p>

<pre><code>x = Artist.objects.get(name="Eminem")
print x.query
</code></pre>

<p>Then I got the error:</p>

<pre><code>AttributeError: 'Artist' object has no attribute 'query'
</code></pre>

<pre><code>from django.db import connection

x = Artist.objects.get(name="Eminem")
print connection.queries[-1]
</code></pre>

python django