I'm working on implementing django-shop, and I'm having a few problems, one of those is that on every page I want it to display at the top infomration about the shopping cart, e.g. it should say:
"Your Cart: 5 items, $35.68 total"
Now, I do not know how to pass the cart information without creating my own modified views for every django-shop page. I could do something ugly, like modify the urls and create my own views. e.g.
urls.py:
import myapp.views as mycustomviews
url(r'^catalog/(?P<path>.+)/product/(?P<slug>[0-9A-Za-z-_.//]+)/$',
mycustomviews.CustomProductView.as_view(),
name='product_detail'
),
(r'^catalog/', include('shop_categories.urls')),
myapp/views.py:
class CustomProductView(CategoryProductDetailView):
def get_context_data(self, **kwargs):
context = super(ProductView, self).get_context_data(**kwargs)
mycart = # figure out how to get the session cart info and put it here
context["mycart"] = mycart
return cont
I REALLY don't want to do this. This is my first shop, and the less I mess with the underlying code, the happier I am. Is there some way I can either access the cart information from my templates, or alternatives pass that information along?
This is actually a general problem for me, there's always information I want to pass along to the templates, and I have no idea how to do it without overloading the views in django-shop