diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-08-26 18:52:49 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-08-26 18:52:49 +0200 |
commit | 3eb99a41ae7c538da28a0acafac194ccc98ed349 (patch) | |
tree | c58c93d887fee773cb8acdd2df6867ee5f051cd1 /ishtar_common | |
parent | 6ff0df3f163b04d43ccd5bca1f951bdf97c7954e (diff) | |
download | Ishtar-3eb99a41ae7c538da28a0acafac194ccc98ed349.tar.bz2 Ishtar-3eb99a41ae7c538da28a0acafac194ccc98ed349.zip |
Django 1.11: fix dashboards - explicit ordering is needed when using distinct
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 19f557511..b2c45c86f 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1409,7 +1409,8 @@ class DashboardFormItem(object): q = cls.objects.filter(**{date_var + '__isnull': False}) if fltr: q = q.filter(**fltr) - return q.filter(**{date_var + '__year': year}).distinct('pk') + return q.filter( + **{date_var + '__year': year}).order_by('pk').distinct('pk') @classmethod def get_by_month(cls, year, month, fltr={}, date_source='creation'): @@ -1419,14 +1420,14 @@ class DashboardFormItem(object): q = q.filter(**fltr) q = q.filter( **{date_var + '__year': year, date_var + '__month': month}) - return q.distinct('pk') + return q.order_by('pk').distinct('pk') @classmethod def get_total_number(cls, fltr={}): q = cls.objects if fltr: q = q.filter(**fltr) - return q.distinct('pk').count() + return q.order_by('pk').distinct('pk').count() class Dashboard(object): |