Add Product To Cart - Django Wednesdays ECommerce 13

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

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

  • @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

  • @JK-nx1wd
    @JK-nx1wd 9 หลายเดือนก่อน

    Thanks John, from here in the UK. A super tutorial again (just recently found you while trying to make sense of a 5 yr old eccomerce tutorial where all the requirements.txt files were out of date so got a bit lost ha .. a big learning curve in this session for sure but a good feeling when get a 200 server code. Think the JavaScript course is next on the cards! :)

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

      Glad you're enjoying it! Yeah this one was a bit tougher than usual!

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

    Whoa that was a bit to take in! I literally know nothing about JavaScript so may need to learn more about that, especially when I'm also trying to understand HTMX (not related to your course here) Great work as always John! Off to the next video as I'm a bit behind :D

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

    Good Morning
    Thank you, i had some issues with the concept of cookies and sessions
    Now i got
    Just finished #13
    Waiting for #14 next week

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

      I have a problem bro

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

    Awesome series! can't wait to next wednesday!

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

      glad you're enjoying it!

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

    Great tutorial John, thanks.
    By the way, anyone having error like this :
    "TypeError: argument of type 'NoneType' is not iterable" in line > if product_id in self.cart. any idea how to solved it?

    • @multizloy
      @multizloy ปีที่แล้ว +2

      I had this problem in ajax(product detail template). So i changed product_id: $('add_cart').val() line for this product_id : '{{ product.id}}'. Hope it will help.

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

      thanks man) you save me )@@multizloy

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

      @@multizloy this helped me! I had error ValueError: Field 'id' expected a number but got 'ID: 1'. in CMD. Change to what you provided and fixed it. Thanks!

  • @mohammadslim8389
    @mohammadslim8389 9 หลายเดือนก่อน +1

    I was trying to do a pricing section on my website using this, however I faced an issue where no matter what button I clicked for my pricing package. it was always the same ID and name being retrieved, I fixed that with var product_id = $(this).val(); in the script
    If anyone was facing the same issue ..
    Thank you for the series. Looking forward for more. You are awesome!

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

      Nice, glad you got it sorted out!

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

      thanks man!! you saved my time

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

    Hey, at 20:15 when i click on the "add to cart" button i get this error in the terminal: ValueError: The view cart.views.cart_add didn't return an HttpResponse object. It returned None instead.
    I tried to solve this but i have no ideia what i did wrong. Can someone help me?

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

      You made a mistake in your code. Check it vs the video to see what.

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

      @@CodemycomI found the problem, I had written something wrong

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

    Is anyone else getting a namespace or reverse error in the url within the code? My vscode is saying it needs a "," at the end of the url.

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

      if your code is identical to mine, you won't get any errors.

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

    Hey John, In this tutorial you didn't use login decorators. Anyone can add product to cart and move to billing and payment without even registering. I hope you will address this small issue in upcoming video.
    You are doing great. Thank you.

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

      Just throw an:
      if request.user.is_authenticated and request.user.is_superuser:
      Into your view...no biggie.

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

    عالی👍امیدوارم موفق باشی😊ادامه بده

  • @王道瑞
    @王道瑞 3 หลายเดือนก่อน

    Hi John,
    Thank you very much for your course. I'm having a bit of trouble here. When I click the cart button, there is no response in the network tab. I’ve checked the code and there are no errors or warnings. Could this be due to an issue with my environment configuration?

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

      No, you just typed the code wrong somewhere

    • @王道瑞
      @王道瑞 2 หลายเดือนก่อน

      ​@@Codemycom Thank you, John, I have founded the misstake in my code, just Cart change to cart. the problem is solved.

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

    I encountered an issue, I can't import Product from store.models. Previously, I was able to import Product into the store directory, i am using PyCharm could the problem be related to that?

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

      If someone faced the same import problem as I did, I found a solution, but I'm not 100% sure it's correct since I'm just a student :D from django.apps import apps
      then ModelName= apps.get_model('dir', 'ModelName')

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

    On the Jsonresponse line I get TypeError: Object of type set is not JSON serializable

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

      Review your code vs. the video to determine you did differently.

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

    would it not be better to instead have my product buy form as a django form that posts data to the view, then the view can handle all the data and all the products to the cart, because my products will have further possible variations for some products, that in turn effects the price, furthermore, I also have things like quantity that need to be processed?

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

      huh?

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

    I have a problem bro ... I don't get any errors and concole doesn't show anything either this code

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

      What's the problem then?

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

      Error is : jquery-3.7.1.min.js:2
      POST 127.0.0.1:8000/product/%7B%%20url%20'cart_add'%20%%7D 404 (Not Found)

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

      This error

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

      I have a problem of cart/add ,I watch three to four time but problem not solve it​@@Codemycom

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

    John in the admin panel, the admin can change password of ANY user through an option given "this form". can you please teach us how to remove this option for the admin? thanks

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

      No, we want the admin to have that ability. That's what it means to be the Admin.

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

      alright thanks for clearing that up :) @@Codemycom

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

    If I log out, it will be gone, right?
    What do people usually use for cart models or sessions?

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

      Yes, we'll build permanence later in the playlist.

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

    I'm get the value error in cart/add and not shown the console in browser

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

      check your code for errors

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

    Woow, congralutions for tutorial, my friend. I'm from Brazil and I follow you here on TH-cam
    When will the next video come out changing the view and cart?

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

      The series is called Django Wednesdays

  • @nuwarindaalbertgrande2062
    @nuwarindaalbertgrande2062 8 หลายเดือนก่อน

    What if I want to install jQuery in my virtual environment, what do I do

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

      Add it to a js directory in a static directory and call it using the regular static django method

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

    In my product.html, I am seeing a error within the JavaScript code on line "url: '{% url 'cart_add' %}',". However, when I run the code on the browser, I am getting a 200 status when clicking on the Add to cart button and the product shows up in the session id within python shell on the terminal. Should I be concerned? I am using VScode as my code editor.

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

      i have the same probleme

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

      You're getting errors and asking if you should be concerned? Of course you should be concerned...you have an error in your code that needs to be fixed. I can't guess what it is...put it aside for a few days to clear your mind, then compare it to the video code to see what you did differently.

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

      @@haitambainy5571 I put up my problem into stack overflow and got it fixed. If you are using vscode as well, you would just need to install a Django extension into vscode. I typed in Django into the search bar and installed the first one by Baptiste Darthenay. What happened for me is that the JavaScript was correct, as shown by John Elder, but vscode didn't understand it and made the line of code into an error. I was recommended to install a Django or Django template extension. Hope this helps

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

      Hi, I'm also using VScode and getting the same "error". I'm pretty sure this just shows because it's django code where it should be javascript and the editor shits itself. So far i've had no actual issues besides the red line underneath

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

      @@americahater2 no clue, I'd never use vscode for python

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

    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 it can update the value without refreshing the page?

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

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

  • @ciangianluca
    @ciangianluca 8 หลายเดือนก่อน

    One thing i dont understand is that you are not relating the models (Product and cart in this case) to the user. So in theory with your code, all user would share the same Cart and Product objects!
    can you please tell me if this is correct?

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

      No, it's not correct.

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

    I am get an error just in this video add/ 500 xhr

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

      what's the exact error?

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

      @@Codemycom thank you I just got resolved with your GitHub thank you very much I watched a lot of videos but your course is special to me you have different way to teach anyone thank you very much

  • @LawalHussein
    @LawalHussein 8 หลายเดือนก่อน

    John pls am having error in adding to cart
    Saying can't convert my request from product Id to integer

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

      You have a typo in your code. Read thru the comments to see that others did too...and how to fix.

  • @LawalHussein
    @LawalHussein 8 หลายเดือนก่อน

    And is there a way to use only python language without using jquery cause some of us don't have knowledge on it

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

      no. But I teach you everything you need in this video, so you do have the knowledge you need.

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

    Can I just use fetch instead of jQuery

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

      If you have to ask, then probably no

  • @itshunter3510
    @itshunter3510 2 หลายเดือนก่อน

    till this video i was going smooth but now facing difficulty in getting these concepts.. i think i need to learn javascript and more about sessions

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

    great as always.

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

      Thanks!

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

      @@Codemycom Do you have a telegram?

  • @armin.falahatkar
    @armin.falahatkar หลายเดือนก่อน

    thanks a lot

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

    Hi best one ever

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

      Thanks!

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

    where is you'r github link

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

      In the pinned comment, like I said in the video.

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

    Amazing

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

    Great tutorial
    By the way, anyone having error like this : TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType' ? pls need help

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

      you just have a typo somewhere...compare your code to the video to discover it

  • @romanbuchta248
    @romanbuchta248 ปีที่แล้ว +2

    O.K. From this point it's a little bit voodoo .... 😧 - but I keep going on ....

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

    Guys! Just be careful. The HTML code in almost all the files is bad. He adds this 10 times and it looks very unprofessional so BE CAREFUL when using it as your resume! This is not a GOOD HTML CODE

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

    💚💚💚💚

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

    I got this error
    "The view cart.views.cart_add didn't return an HttpResponse object. It returned None instead."
    can you help?

    • @ketilkn
      @ketilkn 9 หลายเดือนก่อน +1

      You either forgot to return anything from your cart_add function, or you do not return a JsonResponse there, or your return is missaligned causing it to belong to an unexpected block.

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

      thank you@@ketilkn

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

      @@FadhelMuhammad-u7o What was the mistake?

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

      @@ketilknit was actually in my ajax, it was error when i write like this '{% url 'cart_add' %}', but when i changed it to "{% url 'cart_add' %}" it works

    • @JK-nx1wd
      @JK-nx1wd 9 หลายเดือนก่อน

      @@FadhelMuhammad-u7o thanks - i had the ' parenthesis instead of " too - spotted everything up to this point but that session was one steep learning curve haha

  • @DDEEPCLEANINGSEVICES
    @DDEEPCLEANINGSEVICES 11 หลายเดือนก่อน +1

    Error during template rendering
    In template C:\Users\d\django\ecom\store\templates\product.html, error at line 75
    'cart' is not a registered namespace
    65
    66
    67
    68
    69
    70 // Check if button pressed
    71 $(document).on('click', '#add-cart', function(e){
    72 e.preventDefault();
    73 $.ajax({
    74 type: 'POST',
    75 url: '{% url 'cart:cart_add' %}',
    76 data: {
    77 product_id: $('#add-cart').val(),
    78 product_qty: $('#qty-cart option:selected').text(),
    79 csrfmiddlewaretoken: '{{ csrf_token }}',
    80 action: 'post'
    81 },

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

      line 75 should be: url: '{% url 'cart_add' %}',
      not cart:cart_add

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

      i dont know how but i keep getting the same error. it seems the html tags cant read from the cart app@@Codemycom