Browse Source

Add initial search app

pull/1/head
Hidden Z 14 years ago
parent
commit
0117ec7014
  1. 0
      pyi2phosts/search/__init__.py
  2. 5
      pyi2phosts/search/urls.py
  3. 21
      pyi2phosts/search/views.py
  4. 1
      pyi2phosts/urls.py

0
pyi2phosts/search/__init__.py

5
pyi2phosts/search/urls.py

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('pyi2phosts.search.views',
(r'^$', 'search'),
)

21
pyi2phosts/search/views.py

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
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)
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,
}
)

1
pyi2phosts/urls.py

@ -62,6 +62,7 @@ urlpatterns = patterns('', @@ -62,6 +62,7 @@ urlpatterns = patterns('',
url(r'^faq/$', object_list, extsources, name='faq'),
url(r'^browse/$', object_list, browse_hosts, name='browse'),
url(r'^latest/$', object_list, latest_hosts, name='latest'),
(r'^search/$', include('pyi2phosts.search.urls')),
(r'^postkey/', include('pyi2phosts.postkey.urls')),
(r'^jump/', include('pyi2phosts.jump.urls')),
# Example:

Loading…
Cancel
Save