1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-01-09 14:28:03 +00:00
py-i2phosts/pyi2phosts/search/views.py

19 lines
500 B
Python

from django.db.models import Q
from pyi2phosts.postkey.models import i2phost
from pyi2phosts.lib.generic import HostsListsView
class SearchedHostsListsView(HostsListsView):
""" 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'
template_object_name = 'host_list'
paginate_by = 40