[Fixed]-How to run Django view function once a button is clicked in a template

1👍

I would add two views

  • invite_concert
  • save_concert

At each click, you use the correct URL for that view, the view can return an empty HttpResponse, if you don’t need any answer back.
For the parameters, I like sometimes to add the parameters I need to the HTML of the item, something like

data-concert-id=venues[i].id

But maybe you already have all the required data in your list item. Anyway, you can then retrieve them and use them easily in the data object of your ajax call, like:

{concert-id : $(this).attr('data-concert-id')

Leave a comment