I am trying to update multiple files in fileField in django. I am fetching the objects from the database and i am assigning the new file by iteration over them and then, saving the object in the list. If i use bulk_update it updates all the fields including the FileFields but is not uploading the file and if i iterate over each object and use .save(), then its working fine.
But using .save() function hits the database multiple times. So, i need to use bulk_update
Code
update_list = []
t_obj = FileFieldDetails.objects.filter(ques_key__in=q_key)
for t in t_obj.iterator():
t.value = request.FILES[0]
update_list.append(t)
# Not Working
FileFieldDetails.objects.bulk_update(update_list,['value'])
# Working
for i in update_list:
i.save()