I have Event objects being shown properly. But I can't seem to grab the result from a python function and place it into the template.
For instance, this is my Event model.
class Event(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=200)
location = models.CharField(max_length=200)
students = models.ManyToManyField(StudentProfile, null=True, blank=True)
managers = models.ManyToManyField(ManagerProfile, null=True, blank=True)
def __unicode__(self):
return self.name
def attendees(self):
return len(self.students.count + self.managers.count)
I can successfully pull everything into my template except attendees... For instance within a search context, I'm passing events as results...
{{ result.name }} is passed into my template fine, so is {{ result.location }}.
But {{ result.attendees|length }} won't show.
Any idea why this is? Help would be greatly appreciated.