On 9 août, 23:37, Hayyan Rafiq <hayya...@hotmail.com> wrote: > Okay then which way do u recommend that i should follow in case > i need to displays objects with different no of properties > Example obj has propA and PropB > {{obj.propA}} > {{obj.propB}} > would work but i want it to be dynamic since the no and name of properties > may vary..
Then you need a custom template filter. Something like this should do the trick: # in your templatetags module: @register.filter def get_attribute(obj, name): return getattr(obj, name, u"") # in your template {% load youtemplatetags %} {% for attrname in attributes %} {{ obj|get_attribute:attrname }} {% endor %} -- 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.