So, I have a ManyToManyField relationship between Item1 and Item2. On a webpage, I want to display one of two messages based on whether the two elements are connected or not. I just donβt know how to request my exact element using the template tag {% if%}.
Roughly what I'm looking for,
{% if Item1 is connected to Item2 %} Display Message1 {% else %} Display Message2 {% endif %}
Any tips on how I will do this?
class Profile(models.Model): user = models.OneToOneField(User) name = models.CharField(max_length=50) eventList = models.ManyToManyField(Event, blank="TRUE", null="TRUE", related_name='event_set+') def __unicode__(self): return self.name
Xonal source share