[Fixed]-How to make a function run along with my views

1👍

If PlaySound is not a method of a class, then you don’t need self. use def PlaySound():.

def PlaySound():
    ...

You can then call the method in the view, before you return the response.

def view(request):
    PlaySound()
    return render(request, "page.html")

Leave a comment