Part 3 : How to edit and update image/data into database in Django | Django Image CRUD |

Поделиться
HTML-код
  • Опубликовано: 25 апр 2021
  • In this video, you will learn how to edit and update the data and image in django. When updating the new image, the old image will be deleted.
    Show your support and get complete CRUD source code with DB: fundacodester.com/scripts/dja...
    Code : fundaofwebit.com/django/how-t...
    Playlist link : • Django Image CRUD
    If the video helps you, hit the like button and subscribe to the channel. If you have any doubts or suggestions, drop them in the comments below and i will answer them.
    Thanks for watching
    Buy me a coffee : www.buymeacoffee.com/sharmacoder
    Follow me on instagram : / sharma_coder

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

  • @thehiddentruth2510
    @thehiddentruth2510 2 года назад +1

    Nice.. yo good and simple way

  • @tecnofest7683
    @tecnofest7683 Год назад

    Thank you! great video😎

  • @shatrughanyadav6509
    @shatrughanyadav6509 2 года назад +1

    Your teaching techniques and methods are awesome Sir ❤️❤️ love u

  • @amolgode9843
    @amolgode9843 2 года назад

    Thanks, it works................!

  • @tazul8
    @tazul8 Год назад +1

    Nice tutorial...

  • @TracarYT
    @TracarYT 2 года назад

    bro it reallly helped me alot . tq soo much bro . my dear brother tq sooo much

  • @mrlyrical04
    @mrlyrical04 2 года назад

    When i run this program, i got this error = Could not parse the remainder: ',' from ''edit-prod','

  • @FundaOfWebIT
    @FundaOfWebIT 3 года назад

    Explained very clear.

    • @SharmaCoder
      @SharmaCoder  3 года назад

      Thank you sir.. Keep supporting

    • @ayushishukla3138
      @ayushishukla3138 3 года назад +1

      I got error at request.FILES[' image']
      Multi valuedict

    • @Sandeep-nr3mj
      @Sandeep-nr3mj 2 года назад

      @@ayushishukla3138 same here... Did you get any solution

    • @ayushishukla3138
      @ayushishukla3138 2 года назад

      @@Sandeep-nr3mj yup.. actually form action should be "post"

    • @Sandeep-nr3mj
      @Sandeep-nr3mj 2 года назад

      @@ayushishukla3138 you mean in edit.html action yes

  • @anmolprashar7737
    @anmolprashar7737 Год назад

    How will we get image name?

  • @anmolprashar7737
    @anmolprashar7737 Год назад +1

    How to upload more than one file?

    • @SharmaCoder
      @SharmaCoder  Год назад +1

      Add the multiple attribute in the input tag and in your view file, use a for loop and store them.

  • @ntsakokhoza4134
    @ntsakokhoza4134 2 года назад

    what if you have more than one file

    • @ntsakokhoza4134
      @ntsakokhoza4134 2 года назад

      Please help

    • @anmolprashar7737
      @anmolprashar7737 Год назад

      @@ntsakokhoza4134 I am stuck with the same issue. Are you able to find the solution?

    • @ntsakokhoza4134
      @ntsakokhoza4134 Год назад

      @@anmolprashar7737 yes, I was able to solve it.

    • @ntsakokhoza4134
      @ntsakokhoza4134 Год назад

      @@anmolprashar7737 To update multiple images, you can use the same approach, but you will need to use a ModelForm and a ModelMultipleChoiceField for the images. You can then update the images by iterating over the selected images and saving each one to the database.
      I hope this helps! Let me know if you have any questions.

    • @ntsakokhoza4134
      @ntsakokhoza4134 Год назад

      here's an example:
      from django.shortcuts import render, redirect
      from .forms import MyForm
      def update_images(request):
      if request.method == 'POST':
      form = MyForm(request.POST, request.FILES)
      if form.is_valid():
      // Access the images from the form
      images = form.cleaned_data['images']
      // Update the images in the database
      for image in images:
      instance = MyModel.objects.get(pk=image.pk)
      instance.image = image
      instance.save()
      return redirect('success_url')
      else:
      form = MyForm()
      return render(request, 'update_images.html', {'form': form})