Bharani
0
Q:

check if queryset is empty django template

<ul>
{% for athlete in athlete_list %}
    <li>{{ athlete.name }}</li>
{% empty %}
    <li>Sorry, no athletes in this list.</li>
{% endfor %}
</ul>
1
orgs = Organisation.objects.filter(name__iexact = 'Fjuk inc')
if not orgs:# If any results
    # Do this with the results without querying again.
else:# Else, do something else...
    # Do that...
0

New to Communities?

Join the community