Hi, I'm pretty new to python and django. I have a list of items that I'm displaying, and each item can have zero, one or many images. I want to display the first image if one exists.
I soon found out that I can't do stuff like test: item.images.all().count() in the templates, so I thought I'd add a custom method to the item model like this: def image(self): if self.images.all().count() > 0: return self.images.all()[:1] else: return None I'm coming from ruby... so I thought I might be able to access this from the template as "item.image", but then I realized I have to access it as "item.image()" which the templates don't support. What's the Python/Django way to do this? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---