Django how can i send data to def function in when <a href is clicked

For example, I want to send data "1" when January is clicked

<div class="list-group">
                    <a href="#" class="list-group-item list-group-item-action active">

You have 2 solutions.

  1. Pass the data through the URL with query parameters. So your link would be <a href="{% url 'some-url' %}/?month=1">January</a> and retrieve the data in your view.
  2. Or transform your link to a button in a form : <form action='somewhere'><button value='1' type='submit' name='month'>January</button></form>
Back to Top