Django: Raw SQL with connection.cursor()
<p>I am a complete newbie to Django. I need to perform the following query and use img.img_loc to populate a list of images in a template:</p>

<pre><code>SELECT img.img_loc, author.surname, author.given_name, author.email
FROM image_full AS img
LEFT JOIN author_contact_zzz AS author ON img.pmcid = author.pmcid
WHERE img.pmcid = 545600
GROUP BY img.img_loc, author.email;
</code></pre>

<p>I read the documentations here: <a href="https://docs.djangoproject.com/en/1.10/topics/db/sql/" rel="nofollow">https://docs.djangoproject.com/en/1.10/topics/db/sql/</a></p>

<p>However, I do not understand where the function:</p>

<pre><code>def my_custom_sql(self):
</code></pre>

<p>that they are talking about in the last section is supposed to go to (views.py ?) and what is 'self' in that case, since my view is not defined as a class.</p>

<p>Thanks!</p>