Hi Everyone, I am trying to pass a dictionary with numerical as key and a object as value to my template... i construct it like this: reslibdic[res.result_id]=Library.objects.get(libraryresult__result__result_id=res.result_id)
But, in template, rather than iterating over the dictionary (using for and items) i would like to access them using keys. So, i wrote the following template tag fiter. def hash(h,key): if key in h: return h[key] else: return None And in template i am using it like following. {{ reslibdic|hash:res.result_id }} But, this gives me the primary key of the object NOT the OBJECT itself. I would like to get the object itself so that i can access and print its different values/fields. Any idea? Or am I too stupid not being able to google this successfully since this morning. I can alter the filter say return h[key].<field name> to work. But, i just dont think it is efficient to make one filter for each filed. Thanks a bunch in advance, Gowthaman {code} reslibdic = {} allres = Result.objects.filter(resultslgene__geneid=geneid) for res in allres: reslibdic[res.result_id]=Library.objects.get(libraryresult__result__result_id=res.result_id) {code} -- 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.