1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-01-09 06:18:05 +00:00
py-i2phosts/pyi2phosts/search/views.py
Hidden Z 18266be4c2 search/views.py: fix broken search
It was broken after inroducing different ordering in /browse/.
2015-11-15 19:38:38 +00:00

19 lines
540 B
Python

from django.db.models import Q
from pyi2phosts.postkey.models import i2phost
from pyi2phosts.lib.generic import LocalObjectList
class SearchedHostsListsView(LocalObjectList):
""" Renders list of hosts matching search request """
def get_queryset(self):
q = self.request.GET.get('q', '')
fil = Q(name__icontains=q) | Q(b64hash__contains=q)
queryset = i2phost.objects.filter(fil)
return queryset
template_name = 'search_results.html'
context_object_name = 'host_list'
paginate_by = 40