Take the 2-minute tour ×

I have this in the Google App Engine python code,

class ABC(db.Model):
  StringA = db.StringProperty()

abcs = ABC.all()
template_values = {'abcs': abcs,}
self.response.out.write(template.render(path, template_values))

and this in the index.html,

<script type="text/javascript">
{% for abc in abcs %}
  var id = "{{ abc.ID }}"; // needed the entity ID, the abc.ID doesn't show??
{% endfor %}

What was the right keyword to use for the entity ID, the abc.ID??

Thanks in advance.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

{{abc.key.id}}, assuming you're using Django templates. The ID isn't a property of the object, it's a part of the object's Key; in a Django template (which is what you're using if you're using google.appengine.ext.webapp.template), this is the equivalent to abc.key().id() in Python code.

Note that not all entities have an ID at all; they could have a key name instead if you've set one.

share|improve this answer
Hi Wooble, the {{abc.key.id}} works. Thanks. –  Peter Jan 7 '11 at 4:35

Your Answer


