Django beginner question. I have the following model:
class Leg(models.Model):
startpoint = models.CharField(max_length=50, help_text="examples: 'Smith Elementary' or 'riders' houses'; less than 50 characters.")
endpoint = models.CharField(max_length=50, help_text="examples: 'Smith Elementary' or 'riders' houses'; less than 50 characters.")
riders = models.ManyToManyField(Rider, blank=True)
drivers = models.ManyToManyField(Driver, blank=True)
I make an instance of the model available in a template as 'leg'. In the template, I want to see if, for that instance, there are ANY associated drivers. I've tried {% if leg.drivers %} but that always seems to evaluate to True, regardless of whether there are any drivers or not for the leg.
How do I check to see if there are actually any drivers? Sorry for the basic question but I can't seem to figure it out.
{% if leg.drivers_set.all() %}
– Krystynakshatriya{% if leg.drivers_set.all %}
– Spleenful