Django Ecommerce Website | Add to Cart Functionality | Part 3

Dennis Ivy · 296K views · 2020 · 1:19:04

Open on YouTube

Web developmentPython, Ruby & scripting languagestutorial

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they were following when they hit errors in their own code, such as JSONDecodeError at /update_item/ or missing request attributes.

Recommended by 1 people across 1 different months, 2020 to 2022.

What it is

Part 3 of Dennis Ivy's Django ecommerce series, a 1h19m build-along tutorial. It adds core shop behaviour: cart.js event handlers, an updateItem view with CSRF handling, creating Order and OrderItem records, cart totals, a shipping form and order processing.

What people said

Recommends Asghar Abbasi · 2021-11 · Stack Overflow · on “JSONDecodeError at /update_item/ Expecting value: line 1 column 1 (char 0)”

I’m a beginner. I have tried everything in the Django E-commerce website course, but it does not work for me. I also tried documentation but I didn’t get any solution. I have this error when I go to /update_item/ and the data is not showing up in the terminal: Expecting value: line 1 column 1 (char 0) error screenshot [LINK] tutorial link tutorial link [this video] [this video] cart.js var updateBtns = document.getElementsByClassName('update-cart') for (i = 0; i < updateBtns.length; i++) { updateBtns[i].addEventListener('click', function(){ var productId = this.dataset.product var action = this.dataset.action console.log('productId:', productId, 'Action:', action) console.log('USER:', user) }) } funct

Cites Kanchon Gharami · 2020-09 · Stack Overflow · on “Importing Data from a JSON to django AttributeError: 'WSGIRequest' object has no attribute 'data'”

I am trying to make an E-commerce website from the tutorial series- Django Ecommerce Website | Add to Cart Functionality | Part 3 [this video] in django freamwork. My views.py is: def updateItem(request): data = json.loads(request.data) productId = data['productId'] action = data['action'] print('productId: ', productId) print('action: ', action) return JsonResponse('Item was added', safe=False) My js file is: var updateBtns = document.getElementsByClassName('update-cart') console.log('updateBtns length:', updateBtns.length); for(var i=0; i<updateBtns.length; i++){ updateBtns[i].addEventListener('click', function(){ var productId = this.dataset.product var action = this.dataset.action console.log

Cites Simbeul · 2021-04 · Stack Overflow · on “Why is my Django e-commerce project registering multiple orders for each order made?”

I am learning Python by building a simple e-commerce store using Django. I've been following this tutorial for guidance [this video] . When I pass an order on the site (on localhost), the order is registered 2 times in the backend. Ie: Order #1, Order #2 in the admin panel. I am wondering how I can merge both so 1 order passed on the site = 1 order on the dashboard? In order 1, the field complete is set to True and the Transaction is filled. [LINK] In order #2, the Pickup time & Type are both set. [LINK] Models.py class Order(models.Model): customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, blank=True, null=True) date_ordered = models.DateTimeField(auto_now_add=True) complete = mod

Cites Simon06 · 2021-05 · Stack Overflow · on “JSONDecodeError in Django project”

I'm a beginner. I do everything as in the django ecommerce website course from the link, but it does not work for me. I also tried other stack overflow solutions but they didn't help. I have this error when i go to /update_item/ and the data is not showing up in the terminal: Expecting value: line 1 column 1 (char 0) [LINK] tutorial [this video] cart.js var updateBtns = document.getElementsByClassName('update-cart') for (i = 0; i < updateBtns.length; i++) { updateBtns[i].addEventListener('click', function(){ var productId = this.dataset.product var action = this.dataset.action console.log('productId:', productId, 'Action:', action) console.log('USER:', user) }) } function updateUserOrder(productI

Cites AnonymousUser · 2021-11 · Stack Overflow · on “How to update a HTML data-* attribute without refreshing page”

I'm using Django, how to do this? I followed this tutorial [this video] he made the button so you need to reload the page to get the new value. How can I changed it so it gives the new values, without reloading the page?

Cites Artem · 2022-12 · Stack Overflow · on “AttributeError: 'Order' object has no attribute 'shipping'”

Learning Django with Tutorial [this video] . In the end of lesson I have error: AttributeError: 'Order' object has no attribute 'shipping'. I can't understand what's wrong. Error in PyCharm Terminal I understand that Order must have shipping attribute, but cant find where exactly looking that. Sorry for bad english. My project files: checkout.html from django.db import models from django.contrib.auth.models import User class Customer(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, null=True, blank=True) name = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200, null=True) def __str__(self): return self.name class Product(models.Model): n