Shipping Info Form - Django Wednesdays ECommerce 30

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024

Комментарии • 35

  • @Codemycom
    @Codemycom  6 месяцев назад +1

    ▶ Watch Django Wednesdays Ecommerce Playlist ✅ Subscribe To My RUclips 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 6 месяцев назад

      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!

  • @michaelraymondlegg210
    @michaelraymondlegg210 4 месяца назад

    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  4 месяца назад

      You can do whatever you want.

  • @xStealthFire
    @xStealthFire 5 месяцев назад +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  5 месяцев назад

      Give it a try and see :-)

    • @xStealthFire
      @xStealthFire 5 месяцев назад

      @@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 10 дней назад

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

  • @BlackCodeDev
    @BlackCodeDev 5 месяцев назад

    Why we are not use country list and phone code lists

  • @vahid-m8b
    @vahid-m8b 6 месяцев назад

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

    • @Codemycom
      @Codemycom  6 месяцев назад +1

      Probably not, I have courses on doing that already

  • @namdarcs
    @namdarcs 6 месяцев назад

    FANTASTIC VIDEO Good Sir !!!

  • @Lowenzinho
    @Lowenzinho 6 месяцев назад

    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 6 месяцев назад

      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  6 месяцев назад +3

      We fixed this in video 33: ruclips.net/video/fY2c5OdILgI/видео.html

    • @Lowenzinho
      @Lowenzinho 6 месяцев назад

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

  • @aljay7503
    @aljay7503 6 месяцев назад +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  6 месяцев назад

      watch the video to the end to find the answer

    • @rubiknoob2780
      @rubiknoob2780 6 месяцев назад +1

      same issue,couldnt find the reason behind it

    • @mohammadslim8389
      @mohammadslim8389 6 месяцев назад

      @@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 6 месяцев назад

      @@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  6 месяцев назад

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