@register.filter
def mongo_id(value):
 if isinstance(value, dict):
  return value.get('_id', value)
 return unicode(value)

@ register . filter def mongo_id ( value ) : if isinstance ( value , dict ) : return value . get ( '_id' , value ) return unicode ( value )
retrieve _id value .