pythondjangosessionsatchless

Django session scope


I'm currently developing an e-commerce website using Django 1.6 and Satchless. I have two applications in my project: home and nos_produits.

I'm trying to store the satchless cart object in the django session in order to display the related informations in my templates. Everything works fine in the scope of my application nos_produits (where I add my cart object to the session) but when I navigate through the application "home" it seems that my cart object doesn't exist in the session, i.e {% if 'cart' in request.session %} is not evaluated to true. So my question is what's exactly the scope of a session in django. Is it limited to the application scope where the session is set or to the whole scope of the project?

Thanks in advance.

EDIT

Found the problem: in my "home" view I used render(request, myTemplate.html) instead of using render(request, myTemplate.html, locals())


Solution

  • You haven't shown any code at all, which would have been helpful. But I expect the problem is that you're not passing the request object to the template context in your "home" view: usually this happens automatically if you are using a RequestContext or the render shortcut, which presumably you are doing in the other views.