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>

<p><code>.get</code> returns an instance, not a queryset.</p>

<p>To see the query that is done, do the same thing but with <code>.filter</code>, which does return a queryset:</p>

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

python django