Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 29, 2010 22:34:20

Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Using session list in a template.


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

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 = True
request.session =
for i in range(lectures_list.count()):
request.session += '0'

return render_to_response('main_app/teaching.html',
{'lectures_list' : lectures_list},

Element '0' means, that this part won't be visible. In general it
would look something like . 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) %}
show the details

but naturally i can't write expand_items.

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

Best Regards,

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
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.


Board footer

Moderator control

Enjoy the 23rd of March

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support