I am sure this may have been addressed. I am having this issue for the past week and cannot get past it. I have tried all possible solutions in every site I could find.
Here is my error:
ValueError: The view cart.views.cart_add didn't return an HttpResponse object. It returned None instead. This is my code:
from django.shortcuts import render, get_object_or_404 from .cart import Cart from store.models import Product from django.http import HttpResponse, JsonResponse from django import template from django.http import HttpResponse, HttpResponseRedirect from django.urls import reverse def cart_summary(request): cart = Cart(request) return render(request, 'summary.html', {'cart': cart}) def cart_add(request): # Get the Cart cart = Cart(request) # test to POST if request.POST.get('action') == 'post': # get Stuff product_id = int(request.POST.get('product_id')) # lookup product in DB product = get_object_or_404(Product, id=product_id) # save to Session cart.add(product=product) # Return a reponse cart_quantity = cart.__len__() # Return Repesponse # response = JsonResponse({'Product Name ': product.name}) response = HttpResponse({'qty ': cart_quantity}) return response def cart_delete(request): return def cart_update(request): pass I have tried everything under the sun