Say you have the following method in a model:
def get_images(self):
return ReleaseImage.objects.filter(release=self.id)
And you call it from a template like so:
{% if release.get_images %}{{ MEDIA_URL }}{{ release.get_images.first }}{% endif %}
Does the database get queried twice, or is there some behind-the-scenes optimization that prevents this? It might be highly inefficient if not.