".count" in template does not work for "raw" queries

2014-03-10 Thread bikeridercz
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 t

Re: ".count" in template does not work for "raw" queries

2014-03-10 Thread C. Kirby
The reason .count() doesn't work there is because count() runs a select count(*) query, but that can't run correctly with .raw(). The way to get the count is to cast the Resulting RawQuerySet to a list and run len() on it. This will result in the RawQuerySet getting evaluated however. Alternat