/ Published in: Django
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}}
Now you hace the templatetag, you can use it like this: {{element|pk}}
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
@register.filter(name='pk') def pk(value): if type(value) == type({}): if value.has_key('_id'): value = value['_id'] return unicode(value)