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

22 lines
514 B
Python

from django.db.models import Q
from django.views.generic import list_detail
import settings
from pyi2phosts.postkey.models import i2phost
def search(request):
q = request.GET.get('q', '')
fil = Q(name__icontains=q) | Q(b64hash__contains=q)
qs = i2phost.objects.filter(fil)
return list_detail.object_list(
request = request,
queryset = qs,
template_name = 'search_results.html',
template_object_name = 'host',
paginate_by = 40,
extra_context = {
'title': settings.SITE_NAME,
}
)