Reputation: 7540
I got this in my django template.
{{request.session[0]}}
And I got this error:
Could not parse the remainder: '[0]' from 'request.session[0]'
When I used {{request.session}}
in the template also shows the object hash so I guess the data passing is ok and when I can print session[0] without any trouble then why it would it possibly not work at template?
Upvotes: 1
Views: 97
Reputation: 107287
You can access to array elements with .
in templates :
{{request.session.0}}
from wiki :
Dot lookups can be summarized like this: when the template system encounters a dot in a variable name, it tries the following lookups, in this order:
Dictionary lookup (e.g., foo["bar"])
Attribute lookup (e.g., foo.bar)
Method call (e.g., foo.bar())
List-index lookup (e.g., foo[2])
Upvotes: 2