Dear colleagues,
please help, it seem that count method used in template does not work for collections of records populated in views via direct "raw" query.
Example in view:
recordset = ASSETS.objects.raw('select s.col1, s.col2 from table s where s.col3 = to_char(%s)', [xxx])
Example in template:
{% with total=recordset.count %}
<p class="float-right">{{ total|default:"0" }} record{{ total|pluralize }} found</p>
{% endwith %}
Select returns approx. 20 rows, they are successfully populated into "recordset", they are iterable, can be accessed and displayed with no problem.
However "recordset.count" returns nothing.
In case that the recordset is populated in standard way through ASSETS.object.filter, the "count" method works fine. Unfortunately, "objets.filter" can not be used in this case.
Thanks for help.