i have web that can uploaded file and save it to local storage. but when i got the file back, sometimes the folder of file can be detect but sometimes it’s say not found. i want get the file back to played it at audio controls. first, when i uploaded file, the file cannot be play. second, when i open new web, the file can be played. at the same time, when i uploaded new file again, the new file cannot be played until i open new web. at my terminal:
here’s my html:
<audio controls="controls">
<source src="/media/mp3/{{last_audio.audio}}" type="audio/mpeg">
</audio>
views.py:
def homepage(request):
form = AudioForm()
last_audio = Audio_store.objects.last()
if request.method == "POST":
form = AudioForm(request.POST, request.FILES)
if form.is_valid():
form.save()
audio = form.cleaned_data.get("audio")
print(audio)
context={'form':form, 'last_audio':audio}
return render(request, 'homepage.html', context)
context={'form':form, 'last_audio':last_audio}
return render(request, "homepage.html", context=context)
i was already delete database and create again, but it’s still same. please help me, i don’t know what’s wrong. i was using chrome, incognito and microsoft edge, and the result its same. i don’t know what function cleaned_data, is that delete data?