session variable

0 views
Skip to first unread message

Seth Buntin

unread,
Feb 22, 2007, 10:37:18 PM2/22/07
to Django users
Can I have a list as a session variable?

I want to add potential products to a session list and if an order is
placed iterate over that list and add them to an order.

Or are there better ways to do this?

Thanks.

Seth

Lawrence Oluyede

unread,
Feb 23, 2007, 5:14:44 AM2/23/07
to django...@googlegroups.com
On 2/23/07, Seth Buntin <seth...@gmail.com> wrote:
> Can I have a list as a session variable?

The session object is a dictionary-look-alike. It's available through
request.session.
See <http://www.djangoproject.com/documentation/sessions/>

--
Lawrence, oluyede.org - neropercaso.it
"It is difficult to get a man to understand
something when his salary depends on not
understanding it" - Upton Sinclair

Seth Buntin

unread,
Feb 23, 2007, 9:54:31 AM2/23/07
to Django users
So I can have for instance:

request.session["order_items"] = []

and then in different view I can have:

request.session["order_items"].append(1)

and that append to the session variable?

Honza Král

unread,
Feb 23, 2007, 10:31:28 AM2/23/07
to django...@googlegroups.com
On 2/23/07, Seth Buntin <seth...@gmail.com> wrote:
>

yes, but the session itself doesn't know that you modified it, so you
will have to save it yourself, see
http://www.djangoproject.com/documentation/sessions/#when-sessions-are-saved

>
>
> >
>


--
Honza Král
E-Mail: Honza...@gmail.com
ICQ#: 107471613
Phone: +420 606 678585

Seth Buntin

unread,
Feb 23, 2007, 11:38:37 AM2/23/07
to Django users
Wow....I just needed to read a little bit further.

Thanks.

Seth

Reply all
Reply to author
Forward
0 new messages