P
P
paevlk20072014-07-04 18:27:38
Django
paevlk2007, 2014-07-04 18:27:38

Django, how to make a report grouped vertically and horizontally, like in Excel - PivotTable?

Hi everybody!
Need to make report template in Django:
views.py

def accessories(request, template_name="accessories.html"):
    accessories = Accessories.objects.all().order_by('-created_on')
    ctx = {'accessories': accessories}
    return render(request, template_name, ctx)

template
{% for accessorie in accessories %}
    {{ accessorie.plot }}                       --> Участок
    {{ accessorie.equip }}                     --> Оборудование
    {{ accessorie.work }}                      --> Работа
    {{ accessorie.user }}                       --> Пользователь
    {{ accessorie.created_on|date:"d-m-Y" }} --> Дата
{% endfor %}

Plot No. 1 | Equipment No. 1 | Job #1 | Sidorov | 07/02/2014
Section No. 1 | Equipment No. 2 | Job #2 | Ivanov | 07/02/2014
Section No. 2 | Equipment No. 3 | Job #3 | Petrov | 07/03/2014
Section No. 2 | Equipment No. 3 | Job #1 | Sidorov | 07/04/2014
Report like in Excel, only needed in Django, see file
QUESTION: IS IT POSSIBLE TO MAKE SUCH A REPORT IN DJANGO, how to organize it in templates? THE REPORT PARTICIPATES 2 GROUPINGS, rows and columns.
There is regroup but it groups by one value.
6d4b5726126c49b0b3141c2cdcbe5992.PNG

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
paevlk2007, 2014-07-10
@paevlk2007

Problem solved with django-pandas.

A
Alexander, 2014-07-07
@syschel

The simplest
Z.Y. There is also .annotate() for grouping

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question