Looking for a session cart

64 views
Skip to first unread message

frocco

unread,
Jan 21, 2013, 7:50:13 AM1/21/13
to django...@googlegroups.com
Hello,

I am learning django and want to port an app over from PHP.
In PHP, I use a session cart to store items purchased.
Is there anything for django?

Stefano Probst

unread,
Jan 21, 2013, 8:54:00 AM1/21/13
to django...@googlegroups.com
Did you mean something like "sessions" (example)?

Stefano Probst

unread,
Jan 21, 2013, 8:58:11 AM1/21/13
to django...@googlegroups.com
There is also a finished Shop application if you want looking how other solve this Problem.

frocco

unread,
Jan 21, 2013, 9:44:47 AM1/21/13
to django...@googlegroups.com
I found django-cart, but it seems to write to the database.
I want to keep items in session until they checkout.

Thanks for the link to Shop, I will take a look at that also.

Stefano Probst

unread,
Jan 21, 2013, 11:12:01 AM1/21/13
to django...@googlegroups.com

But this is what "sessions" does. By default a session is saved in the database but you can move it also in a cache (https://docs.djangoproject.com/en/1.4/topics/http/sessions/#using-cached-sessions ). Memcached is realy performant.
You can write by write "request.session['fav_color'] = green" and read by write "request.session['fav_color']" or "fav_color = request.session.get('fav_color', 'red')" then "red" is the default value if "fav_color" is'nt set.

frocco

unread,
Jan 21, 2013, 3:43:09 PM1/21/13
to django...@googlegroups.com
Thanks, I need to look at this, not sure how django-cart knows what records are for each user logged in.

Mario Gudelj

unread,
Jan 21, 2013, 4:24:50 PM1/21/13
to django...@googlegroups.com

Use django-cart. It does store the cart content in db but it stores the session as well, so it will nicely match the user to their cart content according to the cart id stored inside a cookie. It's a breeze to implement with any product model. I highly recommend it.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-i0YYos4f3IJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

frocco

unread,
Jan 22, 2013, 7:22:57 AM1/22/13
to django...@googlegroups.com
Thanks, I tried it last night and it seems like a fit for me, porting my PHP app logic.
Reply all
Reply to author
Forward
0 new messages