I am trying to do an ecommerce and when creating the database it does not update in the checkout.html. page. Below the code.
views.py
def cart(request):
if request.user.is_authenticated:
customer = request.user.customer
order, created = Order.objects.get_or_create(customer = customer, complete = False)
items = order.orderitem_set.all()
else:
items = []
order = {'get_cart_total':0, 'get_cart_items':0}
context = {'items':items, 'order':order}
return render(request, 'store/cart.html', context)
def checkout(request):
if request.user.is_authenticated:
customer = request.user.customer
order, created = Order.objects.get_or_create(customer = customer, complete = False)
items = order.orderitem_set.all()
else:
items = []
order = {'get_cart_total':0, 'get_cart_items':0}
context = {}
return render(request, 'store/checkout.html', context)
checkout.html
{% for item in items %}
<div class="cart-row">
<div style="flex:2"><img class="row-image" src="{{item.product.imageURL}}"></div>
<div style="flex:2"><p>{{item.product.name}}</p></div>
<div style="flex:1"><p>${{item.product.price|floatformat:2}}</p></div>
<div style="flex:1"><p>x{{item.quantity}}</p></div>
</div>
{% endfor %}
it works for cart.html but it does not work for checkout.html and there is no errors shown to look for. Any help will be appreciated.