Shipping Info Form - Django Wednesdays ECommerce 30

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

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

  • @Codemycom
    @Codemycom  9 หลายเดือนก่อน +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

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

      On first glance, I am wondering on line 45 of views.py whether you should check an 'and' condition rather than an 'or' condition before saving the two forms. I haven't tried this yet myself. In other words, should you hold off saving anything to the database if either form possibly has an error. Just curious!

  • @kapibara2440
    @kapibara2440 3 วันที่ผ่านมา

    This is fantastic!🎉

  • @xStealthFire
    @xStealthFire 8 หลายเดือนก่อน +1

    Question about saving both forms at the same time when either form.is_valid( ) or shipping_form.is_valid( ) at 15 minute mark. If one form is valid and one form is not valid, won't this also save the invalid form?

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

      Give it a try and see :-)

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

      @@Codemycom I tried it out and it throws an error if either is invalid. I researched further and it could be that (according to chatgpt) in the .save method it is checking if the data is valid as well, but I am not sure exactly how it does this or what the difference is between that and is_valid().

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

      @@xStealthFire i think you can separete those if statemens. like write if form._is_valid then form.save, and below that write another if shipping_form.is_valid then shipping_form.save. that way if one form is invalid it will only save the valid one

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

    I'm still facing the same problems as the others above! Once we get shipping_user with the user__id=request.user.id, it throws that error. So my user id is 1, and his ShippingAddress id is 3, I'm not getting it on how to relate current_user based on the ShippingAddress' id...

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

      I think the problem resides in the fact that whenever you register a new user, unlike the profile, which is automatically assigned to a new user when registered, the shipping address is not, so if they have no shipping address when we load the update info page, it throws the error saying it doesn't exist. I will try to assign a shipping address to newly registered users as a fix for now I guess :)

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

      We fixed this in video 33: th-cam.com/video/fY2c5OdILgI/w-d-xo.html

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

      @@Codemycom you're the best. Imma save up and get lifetime from codemy

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

    ive deleted the old update user and updated this route, when the website is finished im gonna send you the link as the front end is custom

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

      You can do whatever you want.

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

    Why we are not use country list and phone code lists

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

      Why bother?

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

    Hi John,
    Issue with line (17min12 of the video):
    shipping_user = ShippingAddress.objects.get(user__id=request.user.id)
    Info page is not working when logged as 'user1'
    (although, it works when logged as 'admin')
    Error message:
    DoesNotExist at /update_info/
    ShippingAddress matching query does not exist.

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

      watch the video to the end to find the answer

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

      same issue,couldnt find the reason behind it

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

      @@rubiknoob2780 You are right, because in your user1, you are trying to retrieve info that doesn't exist. I managed to make it work by checking if the ShippingAddress.objects.get exists, if not i created a new Shipping address instance
      So, I substituted shipping_user = ShippingAddress.objects.get(user__id=request.user.id)
      with
      try:
      shipping_user = ShippingAddress.objects.get(user__id=request.user.id)
      except ShippingAddress.DoesNotExist:
      # If it doesn't exist, create a new ShippingAddress instance
      shipping_user = ShippingAddress(user=request.user)
      shipping_user.save()

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

      @@rubiknoob2780 The reason behind it is that in user1 the Shipping address instance is not there, so its displaying an error that there query wasnt able to find it.
      An Approach would be to check if the instance exists and if not then create it
      Substitute: shipping_user = ShippingAddress.objects.get(user__id=request.user.id)
      with:
      try:
      shipping_user = ShippingAddress.objects.get(user__id=request.user.id)
      except ShippingAddress.DoesNotExist:
      # If it doesn't exist, create a new ShippingAddress instance
      shipping_user = ShippingAddress(user=request.user)
      shipping_user.save()

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

      @@rubiknoob2780 Same answer, I address that exact thing at the end of the video...

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

    thank you ❤ Do you deploy the project on the Linux server at the end?

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

      Probably not, I have courses on doing that already

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

    FANTASTIC VIDEO Good Sir !!!

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

      Thanks!