i want to get the last file i was upload and it will be played in templates. but what i make it, every file i was upload, it can be played (so there’s so many audio player). what i want is just show 1 audio player with the last audio i was upload it.
here’s my code html:
{% for record in audio %}
<audio controls="controls">
<source src="/media/mp3/{{record.audio}}" type="audio/mpeg">
</audio>
{% endfor %}
views.py:
def homepage(request):
form = AudioForm()
audio = Audio_store.objects.all()
if request.method == "POST":
form = AudioForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect("homepage")
context={'form':form, 'audio':audio}
print(audio)
return render(request, "homepage.html", context=context)