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
Nice.. yo good and simple way
Thank you! great video😎
Your teaching techniques and methods are awesome Sir ❤️❤️ love u
Thank you.
Thanks, it works................!
Nice tutorial...
bro it reallly helped me alot . tq soo much bro . my dear brother tq sooo much
You're most welcome..
When i run this program, i got this error = Could not parse the remainder: ',' from ''edit-prod','
Explained very clear.
Thank you sir.. Keep supporting
I got error at request.FILES[' image']
Multi valuedict
@@ayushishukla3138 same here... Did you get any solution
@@Sandeep-nr3mj yup.. actually form action should be "post"
@@ayushishukla3138 you mean in edit.html action yes
How will we get image name?
How to upload more than one file?
Add the multiple attribute in the input tag and in your view file, use a for loop and store them.
what if you have more than one file
Please help
@@ntsakokhoza4134 I am stuck with the same issue. Are you able to find the solution?
@@anmolprashar7737 yes, I was able to solve it.
@@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.
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})