title: How to filter querysets dynamically with ajax and dropdown menu
body: <p>I have in my views the following code: </p>
  
  <pre><code>def stato_patrimoniale(request):
      now=datetime.datetime.now()
      now=now.year
      ...
      if Ricavi.objects.count()&gt;0:
              for year, month, totale in(Ricavi.objects.values_list( 'data_pagamento_acconto__year', 'data_pagamento_acconto__month').
                  annotate(totale=ExpressionWrapper(Sum(F('acconto')),
                  output_field=FloatField())).values_list('data_pagamento_acconto__year', 'data_pagamento_acconto__month', 'totale')):
                  if id not in incassi.keys() and  year == now:
                      incassi[id]=list(defaults)
                  index=month-1
                  incassi[id][index]=totale
  
  </code></pre>
  
  <p>The now variable is used to filter my data in the queryset, where my <code>ricavi</code> is the following models: </p>
  
  <pre><code>class Ricavi(models.Model):
      codice_commessa=models.ForeignKey(Informazioni_Generali, on_delete=models.CASCADE, null=True, blank=True)
      # numero_lavorazione
      acconto=models.DecimalField()
      data_pagamento_acconto=models.DateField()
  </code></pre>
  
  <p>Now I want to replace the <code>now</code> variable witha a form that give me the possibility to choose the year and update my views. </p>
  
  <p>I have created another app with the following model that with a form gives the possibility to add new year: </p>
  
  <pre><code>class Timing(models.Model):
      reference_year = models.DecimalField(max_digits=4, decimal_places=0, default="2020")
  </code></pre>
  
  <p>Now I want to create a dropdown button that contains all the <code>reference_year</code> filled and when the client click on one of them, the <code>now</code> variable in my <code>def stato_patrimoniale(request):</code> is updated. How could I get this aim?</p>