1👍
✅
I think you might want to save the form to a model first and update profile_image
after that:
from django.core.files.base import ContentFile
if form.is_valid():
new_player = form.save()
temp_image = new_player.profile_image2
# duplicate the image for "profile_image2"
dup_file = ContentFile(temp_image.read())
dup_file.name = temp_image.name
new_player.profile_image = dup_file
new_player.save()
0👍
Your code is a bit confusing to me. As I understood is that you’re taking the image from profile_image2
and assigning it to profile_image
field? If that is what you are trying then this would be a possible answer:
image = form['profile_image2']
photo = PlayerForm(profile_image=image)
photo.save()
[Beginner here so there might be a slight mistake, but that’s how would I go about and solve this question, if I was doing what you are doing]
Source:stackexchange.com