Building a template to display the cart

The cart_add and cart_remove views don't render any templates, but we need to create a template for the cart_detail view to display cart items and totals.

Create the following file structure inside the cart application directory:

templates/    cart/        detail.html

Edit the cart/detail.html template and add the following code to it:

{% extends "shop/base.html" %}{% load static %}{% block title %}  Your shopping cart{% endblock %}{% block content %}  <h1>Your shopping cart</h1>  <table class="cart">    <thead>      <tr>        <th>Image</th>        <th>Product</th>        <th>Quantity</th>        <th>Remove</th>        <th>Unit price</th>        <th>Price</th>      </tr>    </thead>    <tbody>      {% for item in cart %}        {% with product=item.product %}          <tr>            <td> <a href="{{ ...

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.