Hello,

I've got following problem that i would ask you to solve:
I want to do collapse/expand part of the web page (show details of the
lectures_list elements/don't show them). I wanted to do this by
creating a session object 'expand_items' that would keep information
which details should be visible. In my view I'm creating a table of
items:

def teaching(request):
  lectures_list = Lecture.objects.all().order_by('short_name')

  if lectures_list.count()>0 and (not ('items_collapse_initialized' in
request.session)):
    request.session['items_collapse_initialized'] = True
    request.session['expand_items'] = []
    for i in range(lectures_list.count()):
      request.session['expand_items'] += '0'

  return render_to_response('main_app/teaching.html',
{'lectures_list' : lectures_list},
context_instance=RequestContext(request))

Element '0' means, that this part won't be visible. In general it
would look something like ['0', '0', '1', '1' ...]. The items will be
changed by the simple post method.

My question is how to generate html template in order to show only
expanded areas. It would be something like:

{% for lecture in lectures_list %}
{% if(request.session.expand_items[foreach.counter]) %}
  show the details

but naturally i can't write expand_items[foreach.counter].

Can you help me how to avoid it? Or maybe there's a better way to do
it?

Best Regards,
Jacek

-- 
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.

Reply via email to