浏览代码

Hotfix public page search

No ordering causes warning and fallback to default unfiltered QuerySet
jdcaballerov 5 年之前
父节点
当前提交
4d972571d0
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      archivebox/core/views.py

+ 2 - 1
archivebox/core/views.py

@@ -92,12 +92,13 @@ class PublicArchiveView(ListView):
     template = 'snapshot_list.html'
     template = 'snapshot_list.html'
     model = Snapshot
     model = Snapshot
     paginate_by = 100
     paginate_by = 100
+    ordering = ['title']
 
 
     def get_queryset(self, **kwargs): 
     def get_queryset(self, **kwargs): 
         qs = super().get_queryset(**kwargs) 
         qs = super().get_queryset(**kwargs) 
         query = self.request.GET.get('q')
         query = self.request.GET.get('q')
         if query:
         if query:
-            qs = Snapshot.objects.filter(title__icontains=query)
+            qs = qs.filter(title__icontains=query)
         for snapshot in qs:
         for snapshot in qs:
             snapshot.icons = get_icons(snapshot) 
             snapshot.icons = get_icons(snapshot) 
         return qs
         return qs