Сортировать более одной таблицы отдельно

У меня есть шаблон django, содержащий несколько таблиц с одинаковыми заголовками, и я хочу отсортировать каждую таблицу отдельно. Для этого я использую пакет webstack-django-sorting https://github.com/webstack/webstack-django-sorting

Когда я нажимаю на заголовок в моем примере, он сортирует все 4 таблицы, но я хочу отсортировать только одну таблицу.

РЕДАКТИРОВАТЬ: О, извините, я скопировал неправильный код! У меня есть 4 таблицы с различным содержанием:

  • в ожидании
  • В производстве
  • Готово
  • Не совпадает

Кто-нибудь может дать мне подсказку, как решить эту проблему?

{% extends 'base.html' %}

{% load sorting_tags %}

{% block body %}


<div class="container">
    <h1>Pending</h1>
    {% autosort articles_pending %}
    <table class="table">
        <thead>
            <tr>
                <th>{% anchor production_nr _("Production #") %}</th>
                <th>{% anchor article_nr _("Article #") %}</th>
                <th>{% anchor article_name _("Article name") %}</th>
                <th>{% anchor amount _("Amount") %}</th>
                <th>{% anchor price_offer _("Price") %}</th>
                <th>{% anchor create_date _("Create date") %}</th>
                <th>{% anchor start_date _("Target start date") %}</th>
                <th>{% anchor end_date _("Target end date") %}</th>
                <th>Status</th>
            </tr>
        </thead>
        <tbody>
            {% for articles_pending in articles_pending %}
            <tr>
                <td>{{ articles_pending.production_nr }}</td>
                <td>{{ articles_pending.article_nr }}</td>
                <td>{{ articles_pending.article_name }}</td>
                <td>{{ articles_pending.amount }}</td>
                <td>{{ articles_pending.price_offer|floatformat:2 }} €</td>
                <td>{{ articles_pending.create_date }}</td>
                <td>{{ articles_pending.start_date }}</td>
                <td>{{ articles_pending.end_date }}</td>
                <td>{{ articles_pending.status }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
     <h1>In production</h1>
    {% autosort articles_inproduction %}
    <table class="table">
        <thead>
              <tr>
                <th>{% anchor production_nr _("Production #") %}</th>
                <th>{% anchor article_nr _("Article #") %}</th>
                <th>{% anchor article_name _("Article name") %}</th>
                <th>{% anchor amount _("Amount") %}</th>
                <th>{% anchor price_offer _("Price") %}</th>
                <th>{% anchor create_date _("Create date") %}</th>
                <th>{% anchor start_date _("Target start date") %}</th>
                <th>{% anchor end_date _("Target end date") %}</th>
                <th>Status</th>
              </tr>
            </thead>
            <tbody>
              {% for articles_inproduction in articles_inproduction %}
                <tr>
                  <td>{{ articles_inproduction.production_nr }}</td>
                  <td>{{ articles_inproduction.article_nr }}</td>
                  <td>{{ articles_inproduction.article_name }}</td>
                  <td>{{ articles_inproduction.amount }}</td>
                  <td>{{ articles_inproduction.price_offer|floatformat:2 }} €</td>
                  <td>{{ articles_inproduction.create_date }}</td>
                  <td>{{ articles_inproduction.start_date }}</td>
                  <td>{{ articles_inproduction.end_date }}</td>
                  <td>{{ articles_inproduction.status }}</td>
                </tr>
              {% endfor %}
            </tbody>
    </table>
        <h1>Done</h1>
    {% autosort articles_done %}
    <table class="table">
        <thead>
              <tr>
                <th>{% anchor production_nr _("Production #") %}</th>
                <th>{% anchor article_nr _("Article #") %}</th>
                <th>{% anchor article_name _("Article name") %}</th>
                <th>{% anchor amount _("Amount") %}</th>
                <th>{% anchor price_offer _("Price") %}</th>
                <th>{% anchor create_date _("Create date") %}</th>
                <th>{% anchor start_date _("Target start date") %}</th>
                <th>{% anchor end_date _("Target end date") %}</th>
                <th>Status</th>
              </tr>
            </thead>
            <tbody>
              {% for articles_done in articles_done %}
                <tr>
                  <td>{{ articles_done.production_nr }}</td>
                  <td>{{ articles_done.article_nr }}</td>
                  <td>{{ articles_done.article_name }}</td>
                  <td>{{ articles_done.amount }}</td>
                  <td>{{ articles_done.price_offer|floatformat:2 }} €</td>
                  <td>{{ articles_done.create_date }}</td>
                  <td>{{ articles_done.start_date }}</td>
                  <td>{{ articles_done.end_date }}</td>
                  <td>{{ articles_done.status }}</td>
                </tr>
              {% endfor %}
            </tbody>
    </table>
     <h1>No match</h1>
    {% autosort articles_nomatch %}
    <table class="table">
        <thead>
              <tr>
                <th>{% anchor production_nr _("Production #") %}</th>
                <th>{% anchor article_nr _("Article #") %}</th>
                <th>{% anchor article_name _("Article name") %}</th>
                <th>{% anchor amount _("Amount") %}</th>
                <th>{% anchor price_offer _("Price") %}</th>
                <th>{% anchor create_date _("Create date") %}</th>
                <th>{% anchor start_date _("Target start date") %}</th>
                <th>{% anchor end_date _("Target end date") %}</th>
                <th>Status</th>
              </tr>
            </thead>
            <tbody>
              {% for articles_nomatch in articles_nomatch %}
                <tr>
                  <td>{{ articles_nomatch.production_nr }}</td>
                  <td>{{ articles_nomatch.article_nr }}</td>
                  <td>{{ articles_nomatch.article_name }}</td>
                  <td>{{ articles_nomatch.amount }}</td>
                  <td>
                      <form action="{% url 'change_price' order_id=articles_nomatch.pk article_id=articles_nomatch.article_id %}" method="post">{% csrf_token %}
                      <input type="number" name=new_price id="new_price" step="0.01" value="{{ articles_nomatch.price_offer|floatformat:2 }}" style="width: 5em;" />
                      <input class="btn btn-success myButton" type="submit" value="Save"/>
                      </form>
                  </td>
                  <!--<td>{{ articles_nomatch.price_offer|floatformat:2 }} € <a class="glyphicon glyphicon-edit"></a><a class="glyphicon glyphicon-ok"></a></td>-->
                  <td>{{ articles_nomatch.create_date }}</td>
                  <td>{{ articles_nomatch.start_date }}</td>
                  <td>{{ articles_nomatch.end_date }}</td>
                  <td>{{ articles_nomatch.status }}</td>
                </tr>
              {% endfor %}
            </tbody>
    </table>
</div>

{% endblock %}

0 ответов

Другие вопросы по тегам