浏览代码

更正count

locky 3 年之前
父节点
当前提交
336adfa205
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      controller/LangWord.py

+ 2 - 3
controller/LangWord.py

@@ -230,13 +230,12 @@ class LangWordView(TemplateView):
                     # lk_qs = lk_qs.filter(word_key=searchVal)
                 else:
                     lk_qs = lk_qs.filter(langvalmodel__word_val__contains=searchVal, langvalmodel__la__lang=searchKey)
-            count = lk_qs.count()
-            # lk_qs = lk_qs[(page - 1) * line:page * line].values_list('word_key', flat=True)
             if orderByupdate == 1:
                 lk_qs = lk_qs.order_by('updTime')
             else:
                 lk_qs = lk_qs.order_by('-updTime')
-            lk_qs = lk_qs.values('word_key', 'updTime').distinct()[(page - 1) * line: page * line]
+            lk_qs = lk_qs.values('word_key', 'updTime').distinct()[(page - 1) * line: page * line]  # 去除重复word_key
+            count = len(lk_qs)
             k_list = []
             lw_dict = {}
             for lk in lk_qs: