I'm looking for the right syntax for inside a template to display a model variable that is actually not a field in the database (defined by the mode), but a Model method.
Class Member(model.Models): id = models.IntegerField(primary_key=True, db_column='ID') lname = models.CharField(max_length=150, db_column='LName', blank=True) fname = models.CharField(max_length=150, db_column='FName', blank=True) .... (plus other fields) def contactslistindirectory(self): """Returns a comma deliminted list of all member contacts (with last contact prefixed by and)""" s1=self.contacts.all().filter(indirectory=True) s=list2text(s1) return s The model method "contactslistindirectory() returns a string of the name of the contacts for that member. It's getting that information from another model called Contact which has a ForeignKey connection back to Member. I have a template working that can display {{ member.lname }}, {{member.fname }} and others. The template loops through all members. I want to display in the template for each member the value of what is in contactslistindirectory. I've tried {{ member.contactslistindirectory }} and that doesn't work. I don't know the syntax for displaying the value of a Model Method in a template. I'm sure the answer is right in front of me, but despite searching the documentation for examples, I can't spot it. I can see how the model methods are defined, but as yet have not seen how to use that in a template. Any pointers? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---