Hello
I am here because I am developing an e-commerce application.
But at a certain level of my code when I run my server with the command
python manage runserver
I have an error message
Uncaught ReferenceError: info is not defined--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2fdbf0c6-5f2e-4120-a524-6f3171c50389o%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAByCr6gT6SJ1EHyDMTGKb6Q73rbRJXWnd7XbgOeq7WE%2BLU3sAg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACMwF3U_6LtFunxAm%2BoSjPFuAYyFGQ7QsgctyigqJXCathe8Lw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFzgvyEGOxaYRrpXiW0iPOjdy1tm9LNe1ZOVT7jTkXT56mHh0A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAByCr6gT6SJ1EHyDMTGKb6Q73rbRJXWnd7XbgOeq7WE%2BLU3sAg%40mail.gmail.com.
from django.shortcuts import render
from django.http import JsonResponse
import json
from .models import *
def store(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()
cartItems = order.get_cart_items
else:
items = []
order = {'get_cart_total': 0, 'get_cart_items': 0, 'shipping': False}
cartItems = order['get_cart_items']
products = Product.objects.all()
context = {'products': products, 'cartItems': cartItems}
return render(request, 'store/store.html', context)
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()
cartItems = order.get_cart_items
else:
items = []
order = {'get_cart_total': 0, 'get_cart_items': 0}
cartItems = order['get_cart_items']
context = {'items': items, 'order': order, 'cartItems': cartItems}
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()
cartItems = order.get_cart_items
else:
items = []
order = {'get_cart_total': 0, 'get_cart_items': 0}
cartItems = order['get_cart_items']
context = {'items': items, 'order': order, 'cartItems': cartItems}
return render(request, 'store/checkout.html', context)
def updateItem(request):
data = json.loads(request.body)
productId = data['productId']
action = data['action']
print('action:', action)
print('productId:', productId)
customer = request.user.customer
product = Product.objects.get(id=productId)
order, created = Order.objects.get_or_create(customer=customer, complete=False)
orderItem, created = OrderItem.objects.get_or_create(order=order, product=product)
if action == 'add':
orderItem.quantity = (orderItem.quantity + 1)
elif action == 'remove':
orderItem.quantity = (orderItem.quantity - 1)
orderItem.save()
if orderItem.quantity <= 0:
orderItem.delete()
return JsonResponse('Item was added', safe=False)
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAByCr6gT6SJ1EHyDMTGKb6Q73rbRJXWnd7XbgOeq7WE%2BLU3sAg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/162f2532-e687-42a4-b82f-7b024964a699n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFujGLys9SU1UkFVpA6_7L1OdWZYxyj%2BXWsyEoVxmgE7PParHQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b98d4d1-dbb8-46af-c3cd-18a1b83d2c80%40stacktrace.dk.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFujGLxeFYeTOHYZFJjirXHpFHCv%3D_8Xee9EW2FU66X_tsTgjQ%40mail.gmail.com.