[Fixed]-Many-to-many items in a template: check if any are not empty or none

18👍

{% if leg.drivers %} will always be true, because this will be a many to many manager.
Try {% if leg.drivers.all %} to get all associated drivers.

👤Jingo

1👍

The for … empty template tag is made for this. Simply loop leg.drivers.all and if you want to display some message if there are no drivers, then you can do so in the empty clause.

Leave a comment