Return to Snippet

Revision: 63804
at June 7, 2013 21:14 by viroide

Initial Code
def pk(value):
    if type(value) == type({}):
        if value.has_key('_id'):
            value = value['_id']
    return unicode(value)

Initial URL

Initial Description
It's imposible to read de "_id" field en django templates ( {{element._id}} === error) So, to read it, you must do a templatetag. 

Now you hace the templatetag, you can use it like this: {{element|pk}}

Initial Title
How to read \"_id\" field of an object in django templates

Initial Tags

Initial Language