Friday, March 23, 2012

Re: Accessing objects from a dictionary in templates

Template tag filters like this (made one for each field in the library object) helps me to get what i wanted.... But, that seems too silly to do...

in template
<td>{{ reslibdic|hash2libcode:res.result_id }}</td>


in template tag file:

def hash2libcode(h,key):
    if key in h:
        return h[key].librarycode
    else:
        return None

register.filter(hash2libcode)

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate