Skip to content Skip to sidebar Skip to footer

Update A Django Filefield With Ajax

I'm trying to update an existing objects' FileField with Ajax. A wav blob is created in the browser, and I'm trying to pass it by appending it to a FormData instance: var data = ne

Solution 1:

change your form to this

instance = get_object_or_404(MyModel, id=pk)
form = MyUpdateAudioForm(request.POST or None,request.FILES, instance=instance)

and ajax url to

url:"{% url 'posts:update_audio' pk=instance.pk %}",

Post a Comment for "Update A Django Filefield With Ajax"