I've got a template 'cart_summary.html
' which renders fine when I it appears as an include on another template {% include 'cart/cart_summary.html' %}
.
However when I render it directly from a view function (called by ajax), my context variables do not render as expected:
# views.py
def add_to_cart(request):
...
cart = request.session['cart']
...
return render_to_response('cart/cart_summary.html', {'cart': cart})
my cart_summary.html template -
<a src="{% url cart-page pk=cart.pk %}">
<span> CART ({{ cart.count }}) £{{ cart.get_total }} </span>
<img id="cart_icon" src="{{ STATIC_URL }}images/cart_icon.tiff">
</a>
And this is kind of stuff I'm getting returned to the browser -
<span> CART (<bound method ManyRelatedManager.count of <django.db.models.fields.related.ManyRelatedManager object at 0x106bfa150>>) £ </span>
<img id="cart_icon" src="images/cart_icon.tiff">
What do I need to do to get the properly rendered string?