How to check if Django Queryset returns more than one object?

Viewed 533

Basically I have what I'm hoping is a simple issue, I just want to check if the Queryset contains more than one object but I'm not sure how to do it? What I've written (that doesn't work) is below.

{% if game.developer.all > 1 %} 
   <h1>Developers:</h1>
{% else %} 
   <h1>Developer:</h1>
{% endif %}
2 Answers

Using count() to check the total objects in the QuerySet:

{% if game.developer.all.count > 1 %} 
   <h1>Developers:</h1>
{% else %} 
   <h1>Developer:</h1>
{% endif %}
Related