Django - Dynamic filters in a webpage

Hi everyone, I am still a learner for python django. I’d like to filter dynamically data on the table below

The informations in my html template are :

  <table>
        <thead>
            <tr>
                <th>N°Commande</th>
                <th>Magasin</th>
                <th>Objet</th>
                <th>Date commande</th>
                <th>Montant</th>
                <th>Etat</th>
            </tr>
        </thead>
        <tbody>
        {% for item in query_results %}
            <tr>
                <td>{{ item.numero_commande }}</td>
                <td>{{ item.enseigne}}</td>
                <td>{{ item.Objet}}</td>
                <td>{{ item.Date_commande}}</td>
                <td>{{ item.Montant}}</td>
                <td>{{ item.Etat}}</td>
            </tr>
        </tbody>

Here is an exemple of what I’d like to have (filters on table fields) :

thank you in advance for your help

Vinloup

  1. Create a form with your filter fields
  2. Build a dictionary from the submitted form with keys and values from the form data for those fields containing data
  3. Build a query passing that dictionary in as the keyword arguments for the filter.
1 Like

You could also take a look at this package :slight_smile:

2 Likes