I am kinda new to Couchdb and Django and was trying to extend the default sample (greetings) provided with couchdbkit. while making a basic CRUD example using the existing example, I wasn't able to access the couchdb's document id in the django template
When I run something like this
greetings = Greeting.view('greeting/all', descending=False)
for g in greetings:
print g._id
It prints fine, although when passed it to the template using
return render("home.html", {
"form": form,
"greet": greet,
"greetings": greetings
}, context_instance=RequestContext(request))
Using the similar loop as mentioned above I can access
{% for g in greetings %}
<tr>
<td>{{ g.date|timesince }} </td>
<td>{{ g.author }} </td>
<td>{{ g.content }}</td>
</tr>
{% endfor %}
The author and content, but when I introduced {{ g._id }}
I get an error TemplateSyntaxError at / Variables and attributes may not begin with underscores: 'g._id'
can somebody please explain how do i access the unique couchdb's id in django templates, since I know I can access the "_id" in view.py it isn't a problem with couchdbkit, the concern is a work around probably in view.py to maybe convert _id to id or something.
As mentioned, I am a newbie to django, hence maybe the question might be a little silly in itself.
PS: I am using coucdb 1.0.2, django 1.3.0 and python 2.6
Thanks.
Another option is accessing it using a templatetag
Then in your html code you can access it using:
It saves storing more variables and you won't have to do it for each object you want to access it, which makes it DRYer.