#3435 (Cannot sort by Duration column)

by Luc Saffre · in Developers · assigned to khchine5

Résumé

I can click on a column header to get the grid sorted on this column. But for Duration column in Sessions table it doesn't work. No error message in the JS console, the AJAX call seems correct and gets a response, but it is not sorted.

Concepts sous-jacents

Commentaires

  • 6 ans, 9 mois ago by Luc Saffre about #3435 (Cannot sort by Duration column) : You are right, it is because it is virtual. I forgot that. Another solution is to make it a real field (but read-only and automatically computed at each save()). But at the moment I'd say : let's put this to sleep then, because it was just an observation, there is more urgent work to do.
  • 6 ans, 9 mois ago by khchine5 about #3435 (Cannot sort by Duration column) : This is because the duration virtual field doesn't define a sortable_by option because it is not directly depends on the start_date and start_time and end_date and end_time but on a model method. I think we need to use the annotation way to order this query_set.