def get_context_data(self, **kwargs):
    context['cart'] = []
cart = Cart()
cart.name = book.name
cart.author = book.author.name
cart.publisher = book.publisher.name
cart.price = 123
cart.discount = 12
cart.total = 100
context['cart'].append(cart)
return context


class Cart(object):
    pass
Accessing dictionary by key in Django template