これは、著者が関連する写真モデルにいくつかの写真を持っているかどうかを現在確認する必要があるものです。
{% if author.photo_set.count > 0 %}
<h2>...</h2>
<div style="clear: both;"></div>
<div class="author_pic">
{% for photo in author.photo_set.all %}
<img src="..." />
{% endfor %}
<div style="clear: both;"></div>
</div>
<div style="clear: both;"></div>
{% endif %}
これは正しい方法ですか、それともどういうわけか2つのクエリを回避できますか?
ありがとう。