2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-03 15:52:51 +00:00

[Report] Queryset ordering (#10439)

* docs

* Add new helper

* Update CHANGELOG
This commit is contained in:
Oliver
2025-10-01 15:57:07 +10:00
committed by GitHub
parent c8a646100f
commit 3527e1a359
3 changed files with 45 additions and 1 deletions

View File

@@ -84,9 +84,32 @@ To return an element corresponding to a certain key in a container which support
A number of helper functions are available for accessing database objects:
### order_queryset
The `order_queryset` function allows for ordering of a provided queryset. It takes a queryset and a list of ordering arguments, and returns an ordered queryset.
::: report.templatetags.report.order_queryset
options:
show_docstring_description: false
show_source: False
!!! info "Provided QuerySet"
The provided queryset must be a valid Django queryset object, which is already available in the template context.
#### Example
In a report template which has a `PurchaseOrder` object available in its context as the variable `order`, return the matching line items ordered by part name:
```html
{% raw %}
{% load report %}
{% order_queryset order.lines.all 'part__name' as ordered_lines %}
```
### filter_queryset
The `filter_queryset` function allows for arbitrary filtering of the provided querysert. It takes a queryset and a list of filter arguments, and returns a filtered queryset.
The `filter_queryset` function allows for arbitrary filtering of the provided queryset. It takes a queryset and a list of filter arguments, and returns a filtered queryset.
::: report.templatetags.report.filter_queryset
options: