On Jul 28, 6:24 am, iJames <ijamessa...@gmail.com> wrote: > HI, > > I've got a session object which is a dict. I'm using it to track the > state of screen elements (an expanding tree). > > request.session['mystate'] = {'1':'true', '2','false'} > > In my template I'm looping through the branches: > > object.id is 1 > object.id is 2 > > So: > > I want to test: > > request.session['mystate'][object.id]=='true': > > But how can get that multidimensional dynamic ref into a template with > only dot notation? > > I don't see how I can even do it in the view without stuffing the > information into the model object. > > Any ideas? Thanks much! > > James
You need a very simple custom filter. @register.filter def get_item(obj, key): return obj[key] Now in the template: {% if request.session.mystate|get_item:object.id %} -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.