Update Shopping Cart Button - Django Wednesdays ECommerce 14

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ธ.ค. 2024

ความคิดเห็น • 64

  • @Codemycom
    @Codemycom  ปีที่แล้ว +1

    ▶ Watch Django Wednesdays Ecommerce Playlist ✅ Subscribe To My TH-cam Channel:
    bit.ly/3OBQJfN bit.ly/2IGzvOR
    ▶ See More At: ✅ Join My Facebook Group:
    Codemy.com bit.ly/2GFmOBz
    ▶ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
    Take 50% off with coupon code: youtube50 bit.ly/2VC9WUN
    ▶ Get The Code
    bit.ly/47xAhWJ

  • @fantasyworld1087
    @fantasyworld1087 6 หลายเดือนก่อน

    Your teaching style and method is always mind-blowing. Thanks for making us understand programming.

    • @Codemycom
      @Codemycom  6 หลายเดือนก่อน

      Glad you're enjoying it!

  • @rajatchouhan6617
    @rajatchouhan6617 5 หลายเดือนก่อน +1

    Hi John, i am facing an issue, instead of updating the quantity (1-2-3-4) every time i click on the add-to-cart button, it just creates a new line in the console -
    {qty: 1}
    {qty: 1}
    {qty: 1}
    {qty: 1}
    i also tried it with the product.name and every time i got the same product name even tho i clicked on different products, please help

    • @Codemycom
      @Codemycom  4 หลายเดือนก่อน

      rewatch the video and discover what you did differently from the video.

  • @SamObembe-y2v
    @SamObembe-y2v ปีที่แล้ว +1

    Hi John, enjoying your Django series. I went through the code several times and I can see when I add product to the basket it doesn't seem to update the quantity. Do you have ideas what could be the problem?

    • @Codemycom
      @Codemycom  ปีที่แล้ว +1

      You have a typo somewhere. Put the code away for a few days and look at it again, compare it to the video then. The error will jump right out at you with a fresh pair of eyes.

  • @namdarcs
    @namdarcs ปีที่แล้ว +1

    Thanks John great work as always... I noticed when I "add to cart" from a product page the button does not immediately reflect the quantity unless I change to another page or refresh it... Ill review the code you went through to make sure I didn't miss something... and let you know if I flubbed LOL

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      ha, you definitely missed something...

    • @namdarcs
      @namdarcs ปีที่แล้ว

      @@Codemycom Figured.... do you think I have to go back a few lessons? or just review this one? Sorry just on the road so cant check it right right now

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      @@namdarcs probably this one.

    • @namdarcs
      @namdarcs ปีที่แล้ว

      @@Codemycom Yup I flubbed and its working now... Couple mispells of cart_quantity and missed a . LOL Thanks JOHN!

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      Glad you got it sorted out!@@namdarcs

  • @gymboo1st
    @gymboo1st ปีที่แล้ว

    just arrived at the last lesson, now I will make a Wednesday schedule :D thank you for the efforts, django started to be clearer now.
    I have a question, it's been a month in Python as my first language, do I need to learn JS now or postpone it?

    • @Codemycom
      @Codemycom  ปีที่แล้ว +1

      Depends entirely on your goals. No one said you ever have to learn javascript.

  • @odiblue77
    @odiblue77 5 หลายเดือนก่อน

    Hello :)
    First I want to thank you for this tutorials, you are amazing
    I have one question, maybe you covered it in later videos (haven't seen them yet), after adding product to cart, cart button gets correct value but when I use browsers back button it returns me to previous page but cart button doesn't have new value. When I press refresh button (of f5) it then shows new correct value on cart button. Also when I avoid using browser back button and navigate through webpage, everything works fine. Did some googling and found out that it might be related to chased data. Tried multiple solutions (stack overflow, chatgpt...) and I am not able to force automatic page refresh after user uses browser back button. Any suggestions? or some tips what to look for?

    • @Codemycom
      @Codemycom  5 หลายเดือนก่อน

      that's just how browsers work...don't hit the back button lol why would you? If you really care, you could embed a simple browser refresh javascript tag (we have one in a future video) to your base.html file...but honestly...I don't think you need to. This is a manufactured problem that isn't actually going to affect anyone.

  • @charithmax
    @charithmax 4 หลายเดือนก่อน

    hey, I have a problem like when I hit the Add To Cart button on the product page, it updates the Cart qty but only shows "Cart" without the qty. If I refresh the page then It shows the "Cart"+ "qty" on the top ribbon. Is this a page refresh issue? where should I look into it?

    • @charithmax
      @charithmax 4 หลายเดือนก่อน

      this is sorted. small typo has caused the issue. ty

    • @Codemycom
      @Codemycom  4 หลายเดือนก่อน

      usually is :-)

  • @vahid-m8b
    @vahid-m8b 10 หลายเดือนก่อน

    thank your for learning such simple , i watch many time and exactly write your code but when i use add cart , just add one product to my cart ? can help me!

    • @Codemycom
      @Codemycom  10 หลายเดือนก่อน

      Check the comments below to find the answer.

    • @vahid-m8b
      @vahid-m8b 9 หลายเดือนก่อน

      ​@@Codemycom Must be an item in page for add in cart !!

    • @vahid-m8b
      @vahid-m8b 9 หลายเดือนก่อน

      @@Codemycom Must be just an item in page for add in the cart !!

    • @vahid-m8b
      @vahid-m8b 9 หลายเดือนก่อน

      @@Codemycom Must be just an item for add in the cart !!

  • @lwchafik
    @lwchafik ปีที่แล้ว +1

    I followed all the steps but the button doesn't get updated automatically only if I reload the page or move to another page. Someone can help me with that ??!

    • @Codemycom
      @Codemycom  11 หลายเดือนก่อน

      Just review your code vs the video and figure out what you did differently

    • @locheyoutube5252
      @locheyoutube5252 7 หลายเดือนก่อน +7

      I had a similar issue. Look at the line of code response = JsonResponse({'qty': cart_quantity}) and make sure the colons and spaces match exactly. In the video not only did John change the name but also the number of ": " from the previous line. It is in the views . py file in the carts folder under the def cart_add(request) section.

    • @rukiyaislamkhan7294
      @rukiyaislamkhan7294 7 หลายเดือนก่อน

      @@locheyoutube5252 Thank you. I was stuck at this problem for couple of days. Your comment saved me.

  • @houcembahi507
    @houcembahi507 4 หลายเดือนก่อน

    AMAZING lesson like always. If I may I have a qst, I watched some past playlists and you always used models instead of sessions so my qst is: is it necessary to use sessions and not create a model for carts or is it solely because of the reason it can update value without refreshing the page?

    • @Codemycom
      @Codemycom  3 หลายเดือนก่อน +1

      We will use models for logged in users to save their cart to the database, but sessions for people who aren't logged in

    • @houcembahi507
      @houcembahi507 3 หลายเดือนก่อน

      @@Codemycom Thank you for the clarification, your videos are amazing.

  • @sxmmy7820
    @sxmmy7820 11 หลายเดือนก่อน

    I have a quick question. I have followed the video the cart number updates however, when I change pages it goes back to zero. Do you know what the problem could be?

    • @Codemycom
      @Codemycom  11 หลายเดือนก่อน

      Not specifically...you'll have to check your code vs the video to see what typo you made.

  • @jpnovkidTV
    @jpnovkidTV 10 หลายเดือนก่อน

    followed all the detail but instead of seeing the object in the console am getting the whole html page and the status response is ok
    what might be causing this ?

    • @Codemycom
      @Codemycom  10 หลายเดือนก่อน

      Only one cause...you didn't actually follow all the details.

  • @usman_saadat
    @usman_saadat 6 หลายเดือนก่อน

    When I click on 'add to cart' on the product page, the number updates in the backend. However, in the navbar, the number disappears. When I return to the home page, the cart shows the correct number. When I visit another product page, the cart and the number are correctly displayed. But as soon as I click on 'add to cart', the number disappears again. What's happening here? Can anybody guide me, please?

    • @usman_saadat
      @usman_saadat 6 หลายเดือนก่อน

      update: Turns out the problem was with this line:
      response = JsonResponse({"qty:": cart_quantity})
      I had to remove the first ':' after qty, to fix it. The right code is:
      response = JsonResponse({"qty": cart_quantity})

    • @Codemycom
      @Codemycom  6 หลายเดือนก่อน +1

      @@usman_saadat yeah I was about to tell you that you probably just had a typo somewhere

  • @FadhelMuhammad-u7o
    @FadhelMuhammad-u7o 9 หลายเดือนก่อน

    Hi John, always love your video, so easy to understand
    I've got a problem here
    in my project it's said
    AttributeError at /cart/add/
    AttributeError: 'Cart' object has no attribute '__len__'
    am i missing something
    please can anyone help and guide me
    thanks

    • @FadhelMuhammad-u7o
      @FadhelMuhammad-u7o 9 หลายเดือนก่อน

      def cart_add(request):
      # mengambil halaman cart
      cart = Cart(request)
      #mencoba POST
      if request.POST.get('action') == 'post':

      # mengambil product
      product_id = int(request.POST.get('product_id'))

      #Mencari product di database
      product = get_object_or_404(Product, id=product_id)

      #Menyimpan di sesi
      cart.add(product=product)
      #Jumlah Barang di keranjang
      cart_quantity = cart.__len__()
      # return response
      #response = JsonResponse({'Product Name: ': product.name})
      response = JsonResponse({'qty': cart_quantity})
      return response
      here's my code

    • @Codemycom
      @Codemycom  9 หลายเดือนก่อน

      @@FadhelMuhammad-u7o sounds like you forgot to write the __len__ function in your cart.py file

    • @FadhelMuhammad-u7o
      @FadhelMuhammad-u7o 9 หลายเดือนก่อน

      @@Codemycom i already written the __len__ function before, but when i rewriten the __len__ and save, it works, thanks john

  • @abhi-ij3vj
    @abhi-ij3vj ปีที่แล้ว

    How to done buy now in this project

  • @Ahoura_edits
    @Ahoura_edits ปีที่แล้ว

    Very good

  • @abhi-ij3vj
    @abhi-ij3vj ปีที่แล้ว

    Hy sir plz complete project speedly

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      No we'll do one per week on Wednesdays.

    • @deki90to
      @deki90to ปีที่แล้ว

      you must be from the Philippines with that annoying comment

    • @namdarcs
      @namdarcs ปีที่แล้ว

      You cannot rush greatness friend :)

  • @sma1gdz
    @sma1gdz ปีที่แล้ว

    💚💚💚

  • @GetahunAlta
    @GetahunAlta 10 หลายเดือนก่อน

    Boss [Update Shopping Cart Button - Django Wednesdays ECommerce 14] is to Difficult can you send me Your Github Link please? I wanna clone form your github account this project On my email boss

    • @Codemycom
      @Codemycom  10 หลายเดือนก่อน +1

      Cloning is useless if you don't understand what you're doing. Rewatch the video and learn it.

  • @RittaRamachandran
    @RittaRamachandran 5 หลายเดือนก่อน

    Sir am getting the error while clicking on addtocart btn :The view cart.views.cart_add didn't return an HttpResponse object. It returned None instead..

    • @Codemycom
      @Codemycom  5 หลายเดือนก่อน

      You have a typo in your cart_add views.py code. Compare it to the video to discover what the typo is

  • @alimodaresi7862
    @alimodaresi7862 ปีที่แล้ว

    nice

  • @teovukelic5046
    @teovukelic5046 6 หลายเดือนก่อน

    For some reason i can only add 4 products to a cart. From 0 to 4 it goes all fine and then afer trying to add another one it just stays 4.Any idea what could be wrong?

    • @teovukelic5046
      @teovukelic5046 6 หลายเดือนก่อน

      hmm i have only 4 products in database, which means i can only add 1 piece of each. is that how it should be?

    • @Codemycom
      @Codemycom  6 หลายเดือนก่อน

      @@teovukelic5046 No, you've done something wrong...i Can't guess what...you'll have to carefully compare your code to the video to see.