Is there anyway i can play an audio and then make theHttpResponseRedirect in django?

Like i made this blog in Django where you can like and unlike posts etc..., but when you press unlike I would like to play a sound and then make the request to remove the like. Is it possible to do that? I tried to wrap my head in an if statement, but I'm kinda new to Django so I'm lost

MY Postdetail view

class PostDetailView(DetailView):
    model = Post
    template_name = "post_detail.html"
    context_object_name = 'detail'

    def get_context_data(self, *args, **kwargs):

        context = super(PostDetailView, self).get_context_data()
        total = get_object_or_404(Post, id=self.kwargs['pk'])
        total_likes = total.total_likes()

        liked = False
        if total.likes.filter(
            liked = True

        context['total_likes'] = total_likes
        context['liked'] = liked
        return context

My like function

def LikeView(request, pk):
    post = get_object_or_404(Post, id=request.POST.get('post_id'))
    liked = False
    if post.likes.filter(
        liked = False
        liked = True
    return HttpResponseRedirect(reverse('detail-post', args=[str(pk)]))

Where the function with the audio is called

 <button type="submit" onclick="play()" name="post_id" value="{{ }} "
                            class="btn mb-3 mx-2 btn-outline-danger">unlike
                        </button> | {{ total_likes }}

The audio function

    function play() {
      var audio = document.getElementById("audio");;

  <audio id="audio" src=""></audio>
Back to Top